In shell scripting, a shell such as bash runs a file containing a list of commands (a script). The script is effectively a program and the shell is its interpreter.

learn more… | top users | synonyms

0
votes
0answers
17 views

scan folders for file parallely with shell script [duplicate]

I have multiple folders which i have to scan them real time asynchronously with shell script.Can some one help me. Its like I have folder1/fodler2/folder3 ....,i need to scan these folder for files ...
1
vote
2answers
23 views

How do i run different scripts parallely using shell

I have script1,script2,script3 I have to execute all the three at same time using one shell script.Not one after the other.How do I do that?
7
votes
2answers
349 views

Is there an easy way to log all activity that a shell script does?

Is there an easy way to log all activity that occurs from a shell script to a file? I have a script. It outputs things like echo "instructions", as well as other program output. I know the commands: ...
2
votes
2answers
15 views

I have to use a command in shell script which will give a prompt for Y or N.How do i answer it as Y in shell script afater the command

$ command Are you sure you want to set cOrders to be Y? <Y/N> Y How to i do the answering as Y in shell script
2
votes
4answers
92 views

how can I List files in order

I had an 18GB file I needed to download on a less than great Internet connection. Torrenting wasn't an option. So I busted up the file into 100 segments, and eventually, all of it downloaded. Now I ...
1
vote
2answers
42 views

How do I find and replace in file1 with values from file2

file1 O,tested test,12345 OC,test explore,34567 file2 O,new order OC,new quote I need an output like below: New order,tested test,12345 New quote,test explore,34567
2
votes
4answers
143 views

Using sed, how could we cut a specific string from a line of text?

Using sed, how could we cut a specific string from a line of text? The string -> Email subject: Test email one two Expected response -> test email one two Any help in this regard would be ...
1
vote
2answers
50 views

In Bash or ZSH, is there an opposite to the `clear` command?

Typing clear into a shell creates a bunch of new lines until the output history above is all but hidden. Is there a command or method that does the opposite of clear? That essentially moves your ...
1
vote
2answers
38 views

How can I get a list with the packages selected by apt-get autoremove?

Is there any command that prints only the name of the packages that apt-get autoremove selects? I'm creating a script that updates the kernel, removes the old kernel and the unnecessary packages ...
0
votes
2answers
37 views

How to insert data from text to mysql? [on hold]

I get this text from router via ssh. But I want to insert user(fr-XXX) and macadress(F0:24:75:33:22:11) to mysql routerusers table. Flags: M - mac-cookie # USER DOMAIN ...
0
votes
2answers
156 views

Can't run shellscript with sudo

When I try to run my script like this: sudo ./connector.sh It give me this: sudo: ./connector.sh: command not found What am I doing wrong?
7
votes
5answers
457 views

How do you output the filename in find command while using -exec?

I use the following line to find all sub-directories of the PWD and run svnadmin verify on each directory (I already know that they're Subversion repositories) find ./* -maxdepth 0 -exec svnadmin ...
1
vote
0answers
30 views

parse webpage upto n levels using wget

I am trying to extract URLS from a webpage up to user defined n levels using wget. I tried this wget -r -l$2 --reject=gif -O out.html www.google.com | sed -n 's/.*href="\([^"]*\).*/\1/p'` " It is ...
1
vote
1answer
64 views

how to handle file names with spaces

I am developing a GUI search program. I need help to handle filenames with spaces. I just can't figure it out. Here is my code: #!/bin/bash USERNAME=$(whoami) INPUT=$(zenity --entry) updatedb ...
1
vote
0answers
35 views

How to run program/application in full screen mode

I am running my program/application from command line like sudo ./MyApp and some of programs I run like sudo ./MyShFile.sh ( in .sh file I just call/run my programs). But I want that my program ...
2
votes
2answers
58 views

Shell Programming using sed to delete a line from txt file

I want to remove a line from a .txt file using the grep and sed functions but the output I get does not alter any of my info in the text file. Any suggestions on how to get the desired output? Thank ...
0
votes
0answers
25 views

ssh connection: trigger event/invoke shell script at predefines intervals

On the server side I am trying to achieve something like : after x hours of a user being logged in via ssh I would like to execute a shell script. And I want this time to be configurable per user ...
7
votes
5answers
541 views

how can I take total minutes from time?

My system displayed the time like this 10:42 when i input the command date +%R. I need to take in total minutes of the time. That means like this 642 minutes. Is there any command or shell script for ...
1
vote
6answers
71 views

How to fetch numbers from a file and calculate using shell script [closed]

I have a file named numbers.txt. That contain some numbers like this 1568 14578 2365 41655 9965 ... ... I need to take sum of these numbers. How can i take this using a shell script??
0
votes
1answer
53 views

Drop/Undo sudo privileges on .py file which runs inside a program which runs from sudo previleges

I need to run a program from sudo privileges and I am running .py file inside the program. So when my program runs from sudo then it automatically calls/runs the .py file with sudo. I am running file ...
2
votes
1answer
22 views

What is a (reasonably) secure and automated way to backup my mysql database using (any) free cloud/online services?

I have a mysql database that I use for personal devlopment. I would like to back-it up online using any free (in cost) online storage. (dropbox, google-drive etc...) I am assuming a shell script ...
1
vote
1answer
31 views

Creating custom text expansion for password template

Let me explain. As a security measure, my current password system is a complicated combination of letters and symbols, to ensure a different password is used for each website I use a base password as ...
0
votes
0answers
22 views

Any problem launching script with infinite loop using cron?

If I run a shell script containing an infinite loop using cron @reboot, will that hang up the cron daemon or does cron keep moving and not wait for the job to terminate?
0
votes
2answers
78 views

Shell script options with parsing arguments

I have the shell script CONTROLLER_IP="" if [ "$#" -eq 1 ] then CONTROLLER_IP=$1 else echo "Usage : create_endpoint.sh --controller-ip <Controller IP>" exit 1 fi but its executing ...
0
votes
0answers
19 views

Start Rails Application on Boot Ubuntu

I am trying to make my application Ruby on Rails (OpenProject) starting with the system boot, but to test the script as root, returns me the error: /usr/bin/env:ruby: No such file or directory. My ...
2
votes
4answers
64 views

Remove whitespace from all array elements

I have a array called arrayvar, which is being defined as arrayvar=( $(awk '/'"$vovar"'/,/}/ {gsub("'"$vovar"'"," "); gsub("}"," "); gsub("{"," ");gsub(","," ");print}' temp1 | tr -d '\n' | sed ...
3
votes
1answer
81 views

Conditional file and directory installation in `.deb` Packages

Is it possible to create a binary .deb package with conditional files and directories installation (e.g. installation of an init script in /etc/init.d/ after being confirmed by the user)?
2
votes
5answers
74 views

Add particular strings to an array sed/awk/grep

I have this ciscoFlashCopyStatus OBJECT-TYPE SYNTAX INTEGER { copyOperationPending(0), copyInProgress(1), ...
2
votes
1answer
44 views

Passing Variable into awk gsub

I have this command Here vovar=OBJECTS prvar="$(awk '/'"$vovar"'/,/}/ {gsub("$vovar"," "); gsub("}",": %s,"); gsub("{"," ");gsub(",",": %s,");print}' temp1)" Contents of temp1 ...
0
votes
1answer
46 views

Cannnot run a .sh file in terminator [closed]

I am having trouble running a .sh script file in Terminator, however I can run it perfectly fine in the default terminal Ubuntu comes with(gnome-terminal). This is what I get when trying to run it in ...
7
votes
2answers
150 views

Harmless pranks there for the command line? [closed]

Seeking harmless pranks or April fools for Ubuntu (one-liners), with which I can bring my colleagues laugh. However, it should not damage the system. To broad, ok… Only shell scripts With a maximum ...
0
votes
1answer
29 views

Try to execute a script (adduser.sh) in root /$

I'm a new user to Linux and been practicing using creating/using scripts in bash. I found a script to add new users automatically but when I try to run the script in root, I keep getting the same ...
1
vote
2answers
41 views

Make echo ignore spaces?

I have a file called temp1 sCellEventTrap-03-27 TRAP-TYPE -- CAC Code: 01 ENTERPRISE compaq VARIABLES { scellNameDateTime, scellSWComponent, ...
0
votes
0answers
16 views

OpenVPN --up called scrip does not work properly

I use such command to run my OpenVPN connection (part of script): gw=`netstat -rn|grep UG|awk '{print $2}'` openvpn --config ./openvpn.ovpn --up "./up $gw" >/dev/null 2>/dev/null& So I ...
2
votes
1answer
39 views

create sum, avg and min of file

I have this homework question: create function agg, first argument is filename, second will be sum, avg or min. script will compute sum, average or minimum (dependig on 2. argument) from the ...
0
votes
1answer
23 views

If condition fail skip to end of file

for (( v=0; v<t ; v++ )) do awk '/TRAP-TYPE/{i++}i' $fname >tron if [ "$?" -eq 0 ] then echo "MIB file found" else t=$t-1 fi some other commands echo "MIB not ...
1
vote
2answers
114 views

Looping tr command to remove '\r' in multiple files in a directory

I have about 260 files in a directory. How can I input these files one by one into some thing like this file is an array name file=input stream of multiple files x=0 LOOP tr -d '\r' file2 rm ...
5
votes
5answers
288 views

Compare 2 numerals and copy only similar part sed/grep/awk

Supposing I have a array called a. There are 2 entries in a array a[1] and a[2].So each element contains a numeral value. Both these values have a similar starting numbers however they have different ...
-2
votes
4answers
65 views

Copy a string occurring before a particular pattern.

I am to copy this emuEventTrapInformative from below. -- Traps emuEventTrapInformative TRAP-TYPE ENTERPRISE compaq VARIABLES { scellNameDateTime, shelfId, ...
-2
votes
4answers
143 views

Read number of lines containing a particular string

I have this file: adaptec.mib,sCSISmart1,.1.3.6.1.4.1.795.2.5.0.101,CRITICAL, adaptec.mib,sCSISmart2,.1.3.6.1.4.1.795.2.5.0.102,INFORMATIONAL, ...
0
votes
3answers
83 views

Comparing two strings together

I have array called sev[w] where w ranges from 1 to 21. the array contains the following: CRITICAL INFORMATIONAL CRITICAL INFORMATIONAL INFORMATIONAL INFORMATIONAL CRITICAL CRITICAL ...
2
votes
3answers
109 views

Give files user permissions

I'm having a hard time solving this problem. write a shell script to check the executable rights for all the files in the current directory. if the file doesn't have the user executable right then ...
2
votes
5answers
115 views

Condition that matches all occurrences of a word in a file ad does something

I am to do something like this for (( every occurrence of the word TRAP-TYPE in a file )) do desc="$(< inputfile awk '/DESCRIPTION/ {getline; gsub(/^\s*"/, ""); gsub(/"\s*$/, ""); print}')" ...
-1
votes
2answers
118 views

Copying some parts of file

I am to copy "SNMP Agent is up" and "::=101" and count the number of variables present (example here there are 5) and put them in 3 Different variables. FROM FILE.TXT sCSISmart1 TRAP-TYPE ...
3
votes
5answers
237 views

sed remove last 2 numerals

I have the following. oid=.1.3.6.1.4.1.795.2.5.0.xxx (these 0.xxx represent any random numeral) I want to do the following echo $oid | sed (some commands to remove 0.xxx) and store the resulting ...
0
votes
1answer
34 views

2 Dimensional array Error in shell

#!/bin/bash i=$(awk '{x++} END {print x}' mibwithtraps) echo $i IFS="," while read f1 f2 f3 f4 do echo "hell :$f4" done < mibwithtraps This prints this: 7 hell :CRITICAL, hell ...
1
vote
2answers
31 views

New to script question: 'else' not expected in BASH script

Could someone help if possible. I am trying to resolve an issue I have in this script. I am getting 'else' not expected, but the logic seems to make sense. Scripting is all new to me, but I am ...
1
vote
2answers
70 views

Copy particular text from one file to other using GREP or SED

I am to copy the number 795, and use it another file. This 795 could be any number and can change from file to file. Everything till the enterprises will remain the same even the ending curly ...
0
votes
1answer
34 views

I am getting this error message in the terminal and cannot run / execute shell script on my PC. Why?

I was trying to execute the android.sh file in the terminal from my desktop; I got the following errors in my terminal: $ sudo chmod +x ~/Desktop/android-sdk-linux/tools/android.sh [sudo] password ...
2
votes
2answers
31 views

Checking a floating point value within a range

Just wondering how can I check if a floating point value is within a certain range using "bc" and the conditional statements in bash. Thanks in advance For example,I want to find out if 17.2 is ...