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
36 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
113 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"
-3
votes
0answers
23 views

chkrootkit result, am surely hacked huh? [on hold]

/usr/lib/pymodules/python2.7/.path /usr/lib/python2.7/dist-packages/PyQt4/uic/widget-plugins/.noinit /usr/lib/jvm/.java-7-oracle.jinfo /usr/lib/jvm/java-7-oracle/lib/visualvm/visualvm/.lastModified ...
1
vote
2answers
19 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
43 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
0answers
22 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
votes
0answers
33 views

Convert perl to shell/bash [closed]

I understand C and C++ and new to perl scripting. I must convert the perl script under the following url to shell or bash: ...
0
votes
0answers
20 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
325 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
41 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
148 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
171 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
108 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
21 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
62 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?
14
votes
9answers
623 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
35 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
55 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.
3
votes
2answers
68 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, ...
-1
votes
0answers
15 views

using text browser on linux to display proxy information [duplicate]

I have this question on my project , and can't how can be answer it , could you help me? how can store proxy information Permanently for a text mode browser such as links? I want steps , if you can. ...
0
votes
1answer
30 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
25 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
17 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
17 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
123 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
190 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
5 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
38 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
28 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 ...
1
vote
3answers
138 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
46 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
28 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
21 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
95 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
213 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 ...
7
votes
7answers
530 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 ...
0
votes
1answer
28 views

How to compare float variables in awk?

awk -F, 'NR==FNR{c[$29]=$29;next} NF{print $29 ((c[$29]==$29)?" ":",mismatch")}' $file1 $file2 The value of 29th field, i.e., $29 in file1 was 832.9 and that of file2 was 832.9000. If I compare them ...
0
votes
3answers
44 views

Problem when trying to run shell script : No such file or directory

I'm trying to run the following command on bash: ./home/abcdef/Desktop/jikesrvm/dist/prototype_x86_64-linux/rvm which is giving me a bash: ...
-1
votes
1answer
62 views

How to create logfile for a bash script?

I've written a bash script that runs multiple instances of a program and would like to write the entire output of the script to a logfile. I tried #!/bin/bash touch <.../somewhere/logfile.log> ...
0
votes
0answers
19 views

How to store last email in a file?

I wanto to set my bash detecting incoming e-mails and maybe execute commands in the emails, detecting programmed regular expresions, what commands does let me to do this? I'd like to have a solution ...
1
vote
3answers
48 views

Force “bad” (not 0) return code of terminal command?

I have a framework written in python, and for testing purposes I basically want to do a subprocess (aka shell call) ... that should simply come back with a RC != 0. I tried to invoke some non-existing ...
13
votes
1answer
648 views

opposite of eject command?

I have a ton of CDs to image, and I just got curious. I can eject with the eject command. What command inserts the disk tray back into the CD drive? yes it is the type that can pull the tray back in. ...
4
votes
3answers
277 views

improve bash script

I have a quad core desktop, and i wanted to know the average temprature according to sensors. so i wrote this bash 1 liner. echo `sensors -A | awk {'print $3'} | sed 's/+\|(crit\|0:\|°C//g'` | awk ...
0
votes
1answer
29 views

how to stop using export command

every time I run gdb I have to type export SHELL=/bin/bash or gdb would return exit with code 127 my question how to make this command run every time automatically without need to re type it because ...
31
votes
4answers
2k views

When to use () vs. {} in bash?

I'm studying shell scripting with bash and I need to know the difference between (...) and {...}. How does one select between the two when writing a script?
0
votes
1answer
55 views

How to save working directory in gnome-terminal?

How can I save the current working directory in different tabs in a gnome-terminal? I am looking for a script or a command, that will save the working directory of each open tab, without having to ...
2
votes
2answers
45 views

Writing script for automatic process

My shell is bash and I need to write a script that runs a specific software for each input data in the several folders. For example: gd2p.pl -i /home/WORKDIR/folder1/input1.o Let's say that I have ...
0
votes
1answer
54 views

Open up new terminal and run script with double click in Unity

I want to execute expect -c " spawn ssh user@10.0.0.0 expect \"assword:\" send \"pass\r\" interact " in a new terminal by doing double click in an .sh script. I tried ...
2
votes
1answer
52 views

ip netns monitor not working in a script

I'm trying to use ip netns monitor in a script to react to the creation of new network namespaces, eg: ip netns monitor | while read ACTION NETNS; do echo 'handling it!' done However I never see ...
2
votes
1answer
34 views

Run shell script on keyboard shortcut

I would like to run a shell script on the press of a button. The script works if I run it like usually: sh script.sh. But assigning a shortcut to it doesn't work. How would you do this in Xubuntu ...