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
2answers
38 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
55 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
14 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
27 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 ...
1
vote
1answer
20 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
13 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
112 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
149 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
3 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
30 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
26 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
2answers
95 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 ...
0
votes
0answers
27 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
21 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
18 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
87 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
205 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 ...
6
votes
6answers
335 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
25 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
33 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
47 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
38 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
639 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
267 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
27 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 ...
32
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
47 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 ...
1
vote
2answers
38 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
41 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
40 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
29 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 ...
0
votes
2answers
67 views

How to make the terminal prompt make sound every time i am prompted to write a command?

I want every time i have the command prompt (i.e, end of a command) to get a sound to get attention to the terminal [as i am using laptop \a character is not going to work with me]. The command i want ...
1
vote
1answer
35 views

Error: object “ip” is unknown , try “ip help”

I am trying to run trusted executables through a script. I copied the binary executable /bin/ip to a directory called Tools. I renamed the binary to eip. I have navigated to the directory tools and ...
0
votes
2answers
43 views

Can i make a commad execute in background without producing any output?

Is there a way or an option to make a command run in the background without the need to wait for it to end to get the prompt back? (just like mplayer command to play a music file in the background and ...
0
votes
1answer
27 views

Why output redirection is not working with the mplayer command?

The mplayer command is used to play a media file in terminal or a shell script and i gives some controls over it like move forward, backward in the file, etc. Sometimes i find it annoying so i want it ...
1
vote
1answer
43 views

How to make an export DISPLAY?

I'm execution a Java project on a distant server. My project generates a graphical interface. Here is the shell script that I'm executing on the server side : export ...
0
votes
1answer
28 views

watch internet connection thoguh shell

I just need to run a shell script when an internet connection is available. Is it possible to watch the internet connection arability through Shell scripting. ping google.com is the easy command to ...
0
votes
2answers
48 views

How to highlight second vowel from every word in a file?

I am trying to highlight every second vowel in a word to the colour red. What am I doing wrong? cat room.txt | sed 's:[AEIOU]:$(printf "${\e[1;30m}&${\e[0m}"):i2' Ps. Sorry for making it ...
3
votes
3answers
106 views

Can I call a .cpp program in Bash?

I am new in Bash programming. I want to call my C++ program in Bash file. My program is myProg.cpp: #include<iostream> using namespace std; int main() { cout<<"Salam! ...
3
votes
1answer
92 views

What are the differences between executing shell scripts using “source file.sh”, “./file.sh”, “sh file.sh”, “. ./file.sh”?

Have a look at the code: #!/bin/bash read -p "Eneter 1 for UID and 2 for LOGNAME" choice if [ $choice -eq 1 ] then read -p "Enter UID: " uid logname=`cat /etc/passwd | grep $uid | ...
1
vote
1answer
23 views

Bash script behaves fuzzily

I'm using this bash script to check if the content of two paths install and install1 passed as arguments is the same: #!/bin/sh du -a $1 | grep -Po "[0-9]+\t$1/\K.*" | sort -n > list.txt du -a $2 ...
1
vote
1answer
47 views

cutecom not comunicating

I need some help communicating with a serial port device. I have the serial port set to "auto" IRQ in the BIOS. The device (a Temperature controller) has the following Data protocol: Baud:9600 Tx ...
0
votes
1answer
56 views

How to accept root password through shell script

Is there any way that I can provide root password in the shell script without explicitly entering it through the terminal
1
vote
2answers
195 views

How to send a mail/write to other user through a shell script? How to send EOF?

if [ who | grep $user | grep pts ] then write $user message here EOF fi Here if I execute it, it is blocking at write and I have to enter a ...
3
votes
1answer
146 views

Open URL in default browser (Chromium) from terminal and give browser focus

I am trying to open an URL from the terminal window in my default browser which is Chromium: $ xdg-open 'https://www.google.no/?gws_rd=ssl#q=site:askubuntu.com+xdg-open' >/dev/null This will ...
1
vote
0answers
43 views

How to customize the font style in notify-send?

I am trying to change the format of text appearing in pop-up notification while using notify-send command. Here I saw that it can be done using HTML formatting. But that doesn't seem to be working for ...
1
vote
2answers
157 views

Is there any way to execute a shell script whenever I open a terminal?

I want to display a message showing "welcome to terminal" whenever I open a terminal. Any ideas?
1
vote
1answer
43 views

How can I print a variable to a file?

How can I print the contents of a variable into a text file? For example, I have the following script: #!/bin/bash #My Bash echo "saisir votre nom" read $name I would like to print the contents of ...