Script is series of instructions written in plain text file. The script interpreter (i.e. shell, Python, Ruby, etc.) can read this file and act on the instructions as if they were typed at the command prompt. The interpreter also provides a variety of useful programming features to make your scripts ...

learn more… | top users | synonyms (4)

10
votes
3answers
2k views

How do I periodically turn off showing hidden files?

So, in order to hide some files and folders to unskilled eyes, I modified their names putting a dot to the start of the name. It works, and files are hidden. Nosy people that are not skilled will not ...
10
votes
3answers
9k views

Call script after connecting to a wireless network

Is there a way for me to call a shell script once I connect to a specific wireless network? Reason I want to do this is I have to login to the network before I can start using it and I would like to ...
10
votes
1answer
7k views

How to bind mouse buttons to keys?

I have a Logitech MX400 Laser Mouse which has 5 buttons + 4 for vertical/horizontal scrolling. I would like it set up so instead of horizontal scrolling pressing right on the scrollwheel will send ...
10
votes
2answers
288 views

How can I preserve the executable bit on a file that is synchronized by Ubuntu One?

A script I am working on is in a folder that is synchronized by Ubuntu One. Every time I edit it from another computer, it looses its executable bit and I must manually reapply chmod +x. How can I ...
9
votes
2answers
2k views

Case sensitivity in shell scripting

Consider this Bash script: #!/bin/bash echo Enter any character read char case $char in [a-z]) echo Lower case letter ;; [A-Z]) echo Upper case letter ;; [0-9]) ...
9
votes
2answers
2k views

How to replace my username in a script with variable

I want to make an install script for my home PC and I want to make it more flexible. How to replace my username with current user variable? Example: download to: /home/THISUSER/Downloads/
9
votes
2answers
2k views

Running .sh every 5 minutes

I have a .sh script that downloads a photo from Japanese satellite's server and sets it as a background picture. I've put it into startup list, but how do I run it every, like, 5 minutes, ...
9
votes
3answers
31k 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 ...
9
votes
2answers
2k views

What does the first '.' mean in '. ~/.bashrc'? [duplicate]

I saw a post about fix your alias in .bashrc. And he says after you put your alias in .bashrc , you need to use: . ~/.bashrc I do not quite understand what the first dot(' . ') does here. What's ...
9
votes
3answers
32k views

Get wget output to a variable

How can I do it? I am trying it like this RESULT=`wget $URL` P.S. - Also any recommended sources for learning shell scripting?
9
votes
1answer
487 views

“STR: Command not found” while assigning a value to a variable

I entered the following lines into a shell script called “test.sh”: #!/bin/bash echo Hello World STR=”Hello Again” echo $STR After chmod to executable, I ran the script with ./test.sh. However, I ...
9
votes
4answers
683 views

Print output of code in the middle of the screen

The code below will output whatever in file word by word on the screen. For example: Hello will be displayed for 1 second and disappear. Then, the next word in the sentence will appear for a second ...
9
votes
2answers
315 views

Is there a “don't disturb” option to temporarily hide notifications, like on macbooks?

Does there exist "Don't disturb mode" as is does for OSX device, where you can decided when notification can bother you, or not.. I just installed chrome, and I usually get spammed by group texts ...
9
votes
1answer
2k views

Custom right-click action in Unity Launcher keeps cursor busy for 20 seconds

To have a "minimize window" option through right click on an icon in the Unity launcher (Ubuntu 14.04), I followed the detailed instructions here about changing a .desktop file and made a custom ...
9
votes
2answers
16k views

Writing scripts with arguments?

I want to write shell script that takes an argument, and then applies it to files. Specifically, I want to give a term, and then have it compile term.as with mxmlc ("mxmlc term.as"), then run term....
9
votes
4answers
10k views

Launch an application in Windows from the Ubuntu desktop

I'd like a write a shell script in Ubuntu that does the following: Boot up a Windows 7 guest OS in Virtualbox, if it isn't running already. Run a shell script in Windows, where the shell script is ...
9
votes
2answers
836 views

Difference between $'$foo' and $“$foo”

I am having difficulties figuring out some the nuances between single and double quotes within a variable context I define: foo=pwd then run these: echo $'$foo' Which echos $foo (meaning the ...
9
votes
4answers
19k views

making a bash script executable programatically

I need to create a bash script to create and mount a drive. So, two simple commands. Both "work" when entered at the command line. The script is created and executed every time a normal user logs in, ...
9
votes
3answers
34k views

Create a .desktop file that opens and execute a command in a terminal

I would like to know how to write the Exec command of a .desktop file to open a new terminal and execute a shell script in it. The shell script is working and accessible by all users. When launching ...
9
votes
7answers
20k 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 ...
9
votes
5answers
17k views

How can I process multi-line records with awk in a bash script?

example.txt is below Restaurant: McDonalds City: Miami State: Florida Address: 123 Biscayne Blvd Phone: 911 Restaurant: 5 guys City: Atlanta State: Georgia Address: 123 Peachtree Rd Phone: 911 ...
9
votes
3answers
5k views

How to install multiple PPAs and applications at once?

I'm going to set up a couple of general use computers on one of my lab's work benches. There's a whole bunch of PPA repositories and applications from the Ubuntu repositories that I'd like to install ...
9
votes
3answers
25k views

Proper way to add a user account via bash script

Here's the script code I'm using now: getent group $MYGROUP if [ $? -ne 0 ] ; then sudo su -c "groupadd $MYGROUP" fi sudo su -c "useradd mynewuser -p mypassword -m -g $PRIMARYGRP -G $MYGROUP" ...
9
votes
4answers
12k views

Run (system) script on SSH login and/or logout

I'd like my OpenSSH server to start a script whenever a user logs in using SSH, ideally passing the host name or IP, as well as the user name. Additionally I'd like it to run a script, whenever a ...
9
votes
2answers
2k views

How to run a script when there is a change in your local IP?

Before marking as a duplicate: this is not about dynamic DNS or similar things. I know how to run a script every time my networks goes up; it is a simple matter of adding a script in the directory /...
9
votes
1answer
2k views

Script using sed adds an “e” to the output files

I have a script that adds a new user and creates a virtual host for the users domain name. The script works great with one exception... in /etc/apache2/sites-available/ all of my virtual host files ...
9
votes
1answer
1k views

How can I send commands to specific terminal windows?

I'd like to write a script for opening multiple programs (servers) simultanously in separate terminals - doesn't matter which one - and assign different commands to different terminals with commands "...
8
votes
3answers
1k views

Bash Script to Drag and Drop a File to New Location

I'm sure I'll get my ass handed to me for this question, but I just can't seem to figure it out. I'm new to bash scripting, so go easy on me... I want to be able to drag and drop a file onto a ...
8
votes
4answers
620 views

Ask for user confirmation before executing a script?

Is there a way to get User Confirmation(Like Are you Sure-Yes/No) type dialog box when I execute a script(by double click)? I don't mean in Terminal, but a Graphical confirmation box, something like ...
8
votes
2answers
290 views

Referencing variables in a shell script

In a shell script, if I define a variable such as FOO=25, is there a difference between referencing it as $FOO$ and ${FOO}$?
8
votes
5answers
589 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 ...
8
votes
3answers
4k views

how to detect a file over internet using ping or similar command?

I have a shell script to download some of my stuff over Internet. How can I know if a file exists over the Internet? Let's say I want to know if http://192.168.1.1/backup/01012011.zip exists or not? ...
8
votes
3answers
10k views

Can scripts run even when they are not set as executable?

I can seem to run scripts (.sh) with and without them being set as executable. So where exactly this matters?
8
votes
5answers
677 views

Bash - Check directory for files against list of partial file names

I have a server which receives a file per client each day into a directory. The filenames are constructed as follows: uuid_datestring_other-data For example: d6f60016-0011-49c4-8fca-...
8
votes
2answers
31k views

.sh script won't run [duplicate]

Possible Duplicate: How do I run .sh files in Terminal? I'm trying to install Craftbukkit on my Ubuntu 12.04 server. However, I'm having issues with step seven, which instructs me to run ./...
8
votes
2answers
860 views

How can I pass command line arguments to a script through Dash? (14.04)

I recently asked this question about adding a shell script to Dash: In 14.04 how do I run a bash script I wrote without opening a terminal? It worked perfectly. Follow-up question: How can I ...
8
votes
4answers
40k views

Run a script on login using ~/.bash_login

I need to run a script when I login and logout in my Ubuntu. I tried to put the script in my ~/.bash_login but it didn't work. Is there a better location where I can run my script? My script is ...
8
votes
2answers
11k views

Apply icons to bash scripts

I created a script for XChat according to this answer, and I was wondering if there is anyway to apply XChat icon to it.
8
votes
2answers
1k views

Print return value after program execution

I am wondering how to set option to auto print return value after every program execution in terminal without typing echo $?. Is it something that can be setup? Codeblocks has that feature.
8
votes
4answers
4k views

How to get longest line from a file?

I'm interested to find out the line number of the longest line from a file. For example, if I have a file with the following content: lalala tatatata abracadabra mu mu mu how can I write a bash ...
8
votes
2answers
4k views

How can I convert an iTunes WAV music library to FLAC from the command line?

I have a large music library that is currently managed by iTunes in Windows. When I started out 5 or 6 years ago ripping my music to my PCs I had a fairly basic understanding of audio formats, and I ...
8
votes
3answers
14k views

Ubuntu 14.04 not running Bash scripts in /etc/cron.daily [duplicate]

I have a few scripts (that currently run in a CentOS system) I have moved to a new Ubuntu 14.04 system. These scripts are in the /etc/cron.daily to run once a day. These scripts are to run at the ...
8
votes
2answers
2k views

What is responsible for mounting disks listed in fstab?

What script/init process/whatever is responsible for reading fstab and calling mount, during the boot process?
8
votes
2answers
373 views

How to highlight current screen (or window)?

I'm using two screen setup at work and while it usually helps more than it hurts, I have some issues with it. One of them is problem with trailing focus - sometimes I make mistake of typing on wrong ...
8
votes
2answers
3k views

Displaying colors in the prompt

How to display my prompt in color? I see a lot of text go up my screen, and a lot of crud. Something like (red)myName(red)@(blue)myMachine:~$(blue) would help simplify things a lot. Much Appreciated.
8
votes
1answer
256 views

Get word under cursor in X11

For some scripting, I need to get the word currently under the cursor. Can xdotool or a similar tool get it?
8
votes
2answers
148 views

Is there a software that periodically lets me do mental arithmetic exercises?

I am aware of my lazy nature and need to push myself towards doing some basic mental arithmetic from time to time. Therefore, I am looking for a software that periodically asks me to do a short mental ...
8
votes
3answers
2k views

How can I add a script to nautilus for running selected file as administrator?

How can I add a script to nautilus for running selected file as administrator (not open as administrator)? And if it is possible, I want to run this file as administrator without entering my password.
8
votes
1answer
900 views

Execute shell script or command on idle time

I'm searching for the possibility to execute a shell script or command based on idle time in the bash shell. As an example, if I'm in a SSH session to a server of mine and after X minutes of ...
8
votes
1answer
4k views

Hourly GIT Push

Is it possible for me to automate a Git push every hour via a batch script. I would typically type in this: git add * git commit -m "latest update" git push https://username:password@github.com/...