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)

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
30k 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
4answers
642 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
1answer
7k views

How do I make post-install scripts?

How do I make post-install scripts so when I reinstall ubuntu everything is as I want it? Things I want to achive: Installing PPA installing my programs themes needs to be installed Settings needs ...
9
votes
1answer
717 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
822 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
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
4answers
17k 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
7answers
16k 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
15k 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
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
1answer
826 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 ...
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 ...
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
2answers
1k 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/
8
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, ...
8
votes
5answers
963 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 ...
8
votes
4answers
570 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
285 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
584 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
5answers
567 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: ...
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
2answers
757 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
2answers
596 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
2answers
29k 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
10k 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
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
12k 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
304 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
3answers
29k 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 ...
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
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
847 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
2answers
1k 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 ...
8
votes
2answers
241 views

Get the total listening time from the CLI with banshee

Is there a way I can get total listening time from command line? I want to write a script to keep track of how much time I spend listening to music on a daily basis.
8
votes
1answer
2k views

Script Execution at user logout (non root user)

I am in my university labs running ubuntu 12.10 with unity and I don't have root privilleges. I need to run a script at logout. Is this possible? Note: this is probably a duplicate of this question, ...
8
votes
3answers
516 views

How to run a script when a directory is changed by another user?

I know has been a bit of discussion about topics similar to this. But here is what I am basically trying to do. I have a watch directory called watched and whenever a file is added to that directory, ...
8
votes
1answer
889 views

Execute a shell-script when closing laptop lid

Now I have two scripts and I want to execute them respectively when I close the laptop lip and open it. How can I do this?
7
votes
3answers
2k views

What is the point of the bash Null-operator “:”, colon?

What is the point of the "null" operator in a BASH script? I understand that it is used as a placeholder following an if command when you have nothing to say, but need a command to allow the program ...
7
votes
3answers
2k views

Why do some python scripts begin with #!/usr/bin/env python? [duplicate]

I noticed that some python scripts start with #!/usr/bin/env python instead of #!/usr/bin/python. Are python scripts the only ones that use #!/usr/bin/env? Are there any scripts that start out with ...
7
votes
5answers
1k views

How to send a file as an input to another file?

Through the command shell we can redirect the three standard filestreams so that we can get input from either a file or another command instead of from our keyboard, and we can write output and errors ...
7
votes
3answers
204 views

Same script opened in three different ways produces three different results. Why? [duplicate]

I have a sample script (credit goes to kos): #!/bin/bash cat <(cat /etc/lsb-release) I save this script as somename.sh in my home directory. Now, I try to open this file in three different ...
7
votes
3answers
526 views

Display the current date & time in the window's title

Is it currently/technically possible to display the current date & time (ie: digital clock numbers) to the currently active window? Like appending some text from a script?
7
votes
5answers
800 views

Generating an app list from the old installation to run it on the new installation

I want to shift from ubuntu-desktop 10.10 to ubuntu netbook edition 10.10 on my netbook. Currently, the moment I ssh into ubuntu from my ad-hoc network, ubuntu freezes. It always requires a cold ...
7
votes
3answers
9k 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?
7
votes
2answers
3k views

Execute command from file in current shell

I want to executed command from file (which is script) in current shell in terminal. Example: I have file ch_dir contains following: #!/bin/bash cd /usr Now if I execute file usually as following ...
7
votes
8answers
34k views

Filenames with spaces breaking for loop, find command

I have a script which searches all files in multiple subfolders and archives to tar. My script is for FILE in `find . -type f -name '*.*'` do if [[ ! -f archive.tar ]]; then tar -cpf ...
7
votes
4answers
3k views

Script to Mute an Application

My goal is to be able to mute the Spotify application, not the entire system. Using the command: ps -C spotify -o pid= I am able to find the process ID of Spotify, in this case the ID is "22981". With ...