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

2
votes
2answers
48 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 ...
1
vote
2answers
40 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
15 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.
3
votes
3answers
557 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
27 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
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
2answers
35 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: ...
10
votes
2answers
590 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: ...
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
27 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?
2
votes
2answers
18 views
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
1answer
44 views

How to pass the line number, where the mismatch occurred in awk, to Shell variables?

I am trying to compare two csv files. I want the line numbers to be stored into shell variables or array. I tried something like this: paste <(awk -F, '{print NR,$1}' file1) <(awk -F, ...
1
vote
2answers
49 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
1answer
7k views

How to make a shell file execute by double click

I have tried right clicking on the file selecting properties and then the permissions tab and setting it to execute. However, when I double click the file it opens in gedit. What do I do?
2
votes
4answers
144 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
40 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 ...
1
vote
2answers
53 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 ...
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
468 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 ...
3
votes
2answers
9k views

Shell script issue: cron job script to Restart MySQL server when it stops accidentally

I have this script, I am using it to setup CRON job to execute this script, so it can check if MySQL service is running; if not then it restart the MySQL service: #!/bin/bash service mysql status| ...
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 ...
4
votes
1answer
4k views

Script to add static ip to network interfaces

I've got a little script here that should be pretty self explanatory but I can't figure out why the while loop doesn't handle the functions right. It should show the getinfo function again if the user ...
-2
votes
3answers
9k views

how to check if $1 and $2 are null?

I am running some script which passing the string argument and I want to do if else statement shown as below: if [ $1 != '' ] && [ $2 != '' ] then do something..... but it shown Error ...
1
vote
3answers
314 views

How to get list of all non-removable disk device names (SSD/HDD and SATA/IDE only)?

I need a list of all disk device names (not USB or CD ROM) in the following form DRIVES='sda sdb' so that I can loop through them in a bash script. Ideal solution would not have to install a special ...
1
vote
3answers
1k views

How to write a script to “listen” to battery status and alert me when it's above 60% or below 40%?

I want to make a tool that alerts when battery is below 40% or above 60% so I can start/stop charging accordingly. I know some tools alert when battery is low, that's not enough. Is there a tool that ...
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 ...
0
votes
0answers
118 views

Comment text selection in Mousepad text editor?

Is there a keyboard shortcut, or a command, that I can use to comment a selection spanning multiple lines in Mousepad? This is language dependent, since comments in different programming languages ...
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 ...
6
votes
3answers
11k views

Store output of command into the array

This is command: pdc status -a 2>&1 | grep 'okay' It gives the following output [okay ]: you are currently listening: 33 [okay ]: you are currently listening: 22 [okay ]: you are ...
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 ...
2
votes
4answers
293 views

How to run a shell script on Ubuntu-touch?

I want to run a shell script on my "bq Aquaris E4.5 Ubuntu-Edition" phone in the Terminal App and created a shell script in /home/phablet/Documents/sync.sh #!/bin/sh # sync contacts and calendar with ...
2
votes
1answer
408 views

How to remove element from gsettings array in script?

Array in dbus/gsettings has a format [element1, element2, element3, ...]. Gsettings' interface allows only replacing existing array with another, so for instance, adding another item element can be ...
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??
19
votes
10answers
1k views

How to write a shell script to assign letter grades to numeric ranges?

I want to make a script that would prompt you for a number between 0-100 and then give you the grade based on the number. I'd like it in bash. PS3='Please enter your choice: ' (Something here) do ...
1
vote
2answers
74 views

Unzip a file to its current directory

I've figured out that extracting a .zip you need the path to the directory as well when you are recursively looking through subdirectories. So how do you store the path? This is nearly there but ...
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 ...
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 ...
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
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 ...
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 ...
3
votes
1answer
82 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)?
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 ...
3
votes
1answer
100 views

How to have a video player resume from where I last left off?

I'd like to be able to launch a video player (VLC, SMPlayer) via Terminal, using some command like resume_media and then it will automatically find the most recently played media file (.mkv, mp4 etc.) ...