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
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 ...
-1
votes
4answers
67 views

=0 command not found bash

grep "::=BEGIN" -q < /home/erawson/bin/HP/adaptec.mib CHK= echo $? if ($CHK = "0") ; then echo "failed" else exit fi error is: /home/erawson/bin/try1: line 10: =: command not found
0
votes
1answer
33 views

finding number of array from user input

echo -n "Which station or stations you want to download?" read station ELEMENTS=${#station[@]} for (( i=0;i<$ELEMENTS;i++)); do echo you chose ${station[${i}]} stations to download data done ...
3
votes
4answers
260 views

how to change file extensions in a directory [closed]

I have many files in a directory having extension. .text(2) .text(1) I want to remove the numbers from extension and output should be like .text .text Can anyone please help me with the shell ...
1
vote
2answers
65 views

Generating 2D array in Bash with unknown dimension

just wondering if it's possible to generate a 2D array if the dimension is not known prior to user input. For example if user input 2 2 on the commandline the shell will generate a 2D array base on ...
3
votes
1answer
47 views

Part of shell script not getting executed

I have just started taking baby steps into shell scripting. My script goes something like this: firefox -new-tab -url google.com -new-tab -url yahoo.com clear cd /opt/lampp sudo ./lampp start cat ...
0
votes
0answers
21 views

Run sequence of commands and ssh password

I want to create a script that allows me to run ssh, input the required password, and then execute another command on the ssh console. Is there a way to do that? For example, this is what I would ...
2
votes
1answer
102 views

Find and Rename recursively in folders, subfolders and multiple files

I'm new with shellscript and I'm having some problems trying to do what I need... I want to 'optimize' all my *.png images and found this so I made the bash as it says with: #!/bin/bash pngnq ...
1
vote
3answers
89 views

Bash shell for loop process with two paired variable names

It's common to use bash shell for example to bulk rename plenty files. Usually I used the following structure, for file in ./*.short do # do command done That's for filename with .short extension. ...
4
votes
3answers
104 views

Getting internet browsing history from shell

is it possible to use the shell or generate a shell script to find out the browsing history from the browsers installed on the system? thank you
4
votes
2answers
269 views

Move files to directories depending on their extension [duplicate]

I have a directory with huge number of files with different extensions. What I want to do is to move each extension to a folder with name the extension itself, and those files without extension move ...
0
votes
0answers
15 views

Remote child process doesn't end

file test.sh contains below lines. !#/bin/bash while [ "1" ] do date done This file resides inside machine 10.1.1.3. I want to execute this script from a remote machine 10.1.1.2. Let say from ...
0
votes
1answer
268 views

Execute command on remote machine using telnet in one line

I need to write a script to monitor wlan0 interface of my remote machine. I can do this by executing iwconfig wlan0 repeatedly on remote machine. But how to login to that machine and execute this ...
1
vote
1answer
131 views

How to run streamus app from terminal

I use Streamus to stream music from you tube. I want to know whether streamus can be started from terminal itself. I have asked this question in main software site and the author recommended to use ...
2
votes
1answer
62 views

Is there a way to run a script every time I insert a usb modem?

I would like a shell script to execute each time I insert a USB modem. How would I do this?
0
votes
0answers
39 views

Pass to the script keyboard key pressed after hotkey has invoked a Bash script

I assigned a custom hotkey Ctrl+Q to launch my bash script. #!/bin/bash read -s -n 1 key zenity --info --text "$key pressed" I'd like to have a script to detect which key followed the hotkey. Say ...
0
votes
1answer
23 views

discover if other users are executing the watch command on the machine in which MyOwnCommand is beeing executed

I want to know if there are other users that are running watch on the same machine in which command X is being executed. How can I do that?
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 ...
3
votes
3answers
184 views

Store a filename in a variable minus the extension

File: test.zip Bash script while read filename; do zip_file=${filename} # do stuff done; Value stored in variable = "test"
1
vote
2answers
32 views

Calling Values from a .properties file?

Right now I have a simple script I want to now call a .properties file and then print the results of that file, this is what I have so far #Specific Set Variables SpecficStatus="Pass" #SetVariable ...
3
votes
1answer
97 views

Ubuntu Touch: how to create a launcher to start a shell script?

On my bq Aquaris E4.5 I want to create a launcher button for the App Scope to start a shell script. Is there an easy way to create such a launcher?
1
vote
1answer
41 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, ...
0
votes
0answers
89 views

How to turn ON/OFF screen monitor using shell script and 'xrandr' linux command?

I am trying to turn on and off screen monitor in Ubuntu14.04 using key bindings. I tried following shell script #!/bin/sh output=$(xrandr | grep ' connected ' | awk '{print $1}' | head -1) ...
4
votes
2answers
443 views

How to create a rotation animation using shell script?

I looking for a script that creates a rotating animation using character /,-, | and \. If you continuously switch between these characters it would look like its rotating. How to make this?
2
votes
2answers
76 views

How to set environment variables separated by dots

I have to set an environment variable separated by dot in my tomcat startup script. For example host.name=localhost I know shell doesn't accept dot separated variables. Is there a work around ? I ...
3
votes
2answers
194 views

changing string with sed, where did it go?

$ cat test-paths.txt test/sub2/configuration.php test/sub3/configuration.php test/configuration.php test/sub1/configuration.php $ cat find-host-test #!/bin/bash for i in `cat test-paths.txt` do ...
1
vote
2answers
688 views

How can I use “find” in a shell script to search from the current directory?

I want the program to look like this : read a if[ find . name $a ]; then echo "You found the file" else "You haven t found the file" fi
1
vote
4answers
137 views

bash shell script

How do I write a bash shell script that requests the user's name, verify that it exists and, if it does, show the following information: Username: xxxx User ID: xxxx Group ID: xxxx Shell: / bin / xxx ...
0
votes
0answers
29 views

Bash script not creating screen

I have a script that I wish to run on a screen. The screen that already exists is killed correctly, however the screen is not created and the command not run. Any ideas? #!/bin/sh screen -S attorney ...
0
votes
3answers
420 views

for loop syntax in shell script [duplicate]

I run below script: for (( i=1; i <= 5; i++ )) do echo "Random number $i: $RANDOM" done I am getting below Error: Syntax error: Bad for loop variable why this syntax is not working?
19
votes
10answers
986 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
votes
1answer
91 views

Command to delete a file? [duplicate]

The title says it all. I am trying to write a shell script that deletes a persistent but unnecessary folder in my home directory upon execution. So, I ask you fellow Ubuntu users, what is the terminal ...
0
votes
2answers
234 views

Executing root commands without root password within a shell script [duplicate]

Is it possible to write a shell script in which we can include the root commands, and execute it without entering the root password over the terminal.
4
votes
2answers
86 views

Ctrl+C command is not terminating infinite (while) loop

I have this little script. When I start it and the terminal has the focus Ctrl+C stops feh and then the while loop starts feh again. I am expecting that, as long as the terminal(!) has the focus, ...
0
votes
1answer
32 views

Is it possible to edit the .bash_login file for the second time?

I accidentally wrote an error command in the .bash_login file. I need to edit the file to solve this problem but I can't do that anymore. The error is about the .bash_login isn't a writable file ...
0
votes
1answer
47 views

How to remove index.php from each folder and subfolder?

My server got hacked and in each folder and subdirectory index.php was placed. I removed index.php in main folders and was able restore my website. However hacker placed index.php in each ...
0
votes
0answers
21 views

Loop not getting exicuted for a particular date

I has a file with dates of the formats "2015-04-10" and "Apr 20". so i wrote this piece of shell script to extract the lines matching a date and store it in a separate file. the date is given in ...
0
votes
1answer
104 views

ambiguous redirect

The error is: line 20: $1: ambiguous redirect what could be the problem #! /bin/bash while read line do string=$line array=(${string//,/ }) fileName=${array[0]}_"final_fitness.out" ...
5
votes
1answer
145 views

Bash always evaluate Regex as true

In a script, there's these lines #!/bin/bash ... if ! [[ $SCREEN_NAME =~ ^[a-zA-Z0-9_.-]+$ ]]; then echo "The Server title contains invalid symbole. Only a-z A-Z 0-9 - _ . are allowed" exit 1; ...
7
votes
3answers
367 views

How can I start up an application with a pre-defined window size and position?

I'm wondering is there any way to achieve the affect of the Ctrl-Alt-Keypad shortcuts in Unity using terminal commands instead? I want a command that sets a gui window to half the size of the screen, ...
0
votes
0answers
10 views

QJoypad profile switch on program close

I've just started playing with qjoypad on my ubuntu HTPC. I like it because it lets me use my xbox controller as a mouse, and switch profiles. I've read that xboxdrv lets you do the same, but I've ...
2
votes
1answer
53 views

Reset hibernation delay from command line

My hibernation on Ubuntu 14.04 LTS works fine. But someone keeps changing its delay to never hibernate. I am tired of paying days' worth of electricity for 10 minutes usage a day. Is there a way I ...
1
vote
1answer
30 views

Script that prevents the software to run unless other associate software is already running

I have a situation here. We wanted to prevent a software to run successfully unless the other software is already running. If the script has been run, it run the main software and it will check if the ...
2
votes
4answers
283 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 ...
1
vote
1answer
86 views

How to autostart a shell script on Ubuntu-touch?

I want to start a shell script on my bq Aquaris E4.5 Ubuntu-Edition whenever I switch on the phone to syncronize my calendar and contacts via syncevolution with my owncloud server. How can I ...
0
votes
0answers
57 views

How to press ENTER in Nano on Ubuntu-touch via abd?

When I'm connected to Ubuntu Touch (bq Aquaris E4.5 Ubuntu-Edition phone) via adb shell and I'm editing a shell script with Nano. How can I press ENTER to save changes? Nano does not accept the ...
1
vote
1answer
25 views

Script that put filenames at working directory in text files with some additional strings

I need to make a script that put filenames at working directory (with specifical extension) in text file with some additional strings: For example: if I interested in files with extension "i" and ...
5
votes
2answers
161 views

How do I tell a shell script my password?

I've been trying to create a script that runs sudo apt-get update and sudo apt-get autoremove whenever I log in. It goes like this: #!/bin/bash (sudo apt-get update) (sudo apt-get autoremove) But ...
4
votes
3answers
239 views

How to use double substitution in awk?

To print the fields at 29th column in two files I used paste <(awk -F, '{print $29}' PreRefFile.csv) <(awk -F, '{print $29}' Txlog.csv) This worked fine. To print all the fields starting from ...
8
votes
7answers
2k views

Exit terminal after running a bash script

I am trying to write a bash script to open certain files (mostly pdf files) using the gnome-open command. I also want the terminal to exit once it opens the pdf file. I have tried adding exit to the ...