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

1
vote
2answers
44 views

bash - can shellcode be made from a bash script?

I was thinking it can't, since there's not really a binary for bash scripts, but having to write a C program every time you need to generate shell code for a single command is just a pain.
0
votes
1answer
16 views

source a config value with variables

Example:I have a config file where i want below to have date in the value path=/var/opt/[date]/yellow date is something i want to read from argument of the script which sources above config file.
2
votes
3answers
57 views

shell sript to read source file and use the key in the script

#!/bin/bash source /data/output/QAScripts/conf.ini var=$($1path) echo $var conf.ini is the config file which has LSTpath=/data/bb/loader I get below below error. Where am I going wrong. ./file ...
3
votes
3answers
652 views

Syntax error near unexpected token `('

When I use below code in Ubuntu terminal, it works fine: rm !(*.sh) -rf But if I place the same line code in a shell script (clean.sh) and run shell script from terminal, it throws error as this ...
1
vote
2answers
30 views

Concatenate multiple files without header

I have several directories ("amazon", "niger",...), in which I have several subdirectories ("gfdl", "hadgem",...), in which I also have several sub-directories ("rcp8p5", "rcp4p5",...). In this last ...
0
votes
2answers
36 views

Cannot open zip created with shell script [duplicate]

I try to make a backup script, but when i create a zip with the script, and use cd myzip it sais that it dosnt exitst even when i can see it on the server with FileZilla. This is my script: ...
0
votes
2answers
37 views

End of file syntax error shell scripting [on hold]

#!/bin/bash source conf.ini inotifywait -m -e create /$1path | while read file; do if ($(echo $word | head -c 1)"=$1 then echo $file cd $1inputpath ls -l |grep $file* zcat $file* > ...
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
28 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?
11
votes
2answers
611 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
19 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
97 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
50 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
145 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
54 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
41 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
41 views

How to insert data from text to mysql? [closed]

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
165 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
472 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
31 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
66 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
42 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
26 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
543 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
72 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
57 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
23 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
80 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
20 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
65 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
83 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
47 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
154 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
30 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
46 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
18 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
40 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
119 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
144 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
85 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
111 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
116 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}')" ...