Bash is the shell used in Ubuntu's command-line interface.

learn more… | top users | synonyms (1)

4
votes
2answers
1k views

How to go back to previous line of a script in terminal?

I am trying to write a script but I'm stuck here. See the code please! aug@august:~/play$ for i in {1..100..4} > do > echo "august" > touch august $i+$2 > mkdir dir Is there any way to ...
26
votes
4answers
9k views

What is the purpose of the -9 option in the kill command?

Is there a difference between kill -9 212121 and kill 212121
8
votes
2answers
285 views

What is the program that suggests installable packages?

One of the features of Ubuntu that I really like is the one that suggests packages to install if you try to run a program that isn't installed, like this: $ nmap The program 'nmap' is currently not ...
1
vote
1answer
177 views

can't control pianobar after using echo

I have a script that starts pianobar (pandora player) and autoloads into tty2 after booting. I'm running Ubuntu Precise 12.04. it's a pretty simple script: #!bin/bash sleep 5 echo "2" | ...
5
votes
2answers
1k views

Source or dot operator overriding execute permission?

If I have turned off execute permissions on hello.sh and try to execute it ~$ sudo chmod 0666 hello.sh ~$ ./hello.sh -bash: ./hello.sh: Permission denied I get the permission error. But I can ...
2
votes
2answers
924 views

Why wont my pipeline work?

I am trying to make a bash script that will find all the mp3s in my Downloads folder and move them into a music folder. Why won't this line work? find ./ -type f -name \*.mp3 | mv *.mp3 ...
2
votes
2answers
1k views

Bash: command not found

I have a script that needs to know the processor architecture. I'm doing this way: if [["$(uname -m)" = "x86_64"]]; then wget ...
5
votes
2answers
7k 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 ...
0
votes
2answers
298 views

When should you push variables in quotes in boolean conditions? [closed]

Are the following two boolean expressions the same? if [ -n $1 ] ; then if [ -n "$1" ] ; then If not - When should you put a variable in quotes?
5
votes
4answers
969 views

Reuse last line on terminal

When one issues a command that does not exist in the terminal, it results in: The program 'programname' is not installed. You can install it by typing: sudo apt-get install programname Is there ...
0
votes
1answer
103 views

Where I'm making the mistake in here document?

I read the use of here document. I tried something like this: echo $* <<End anto End What I'm trying here is, when I run this script rather than taking input from command line, I'm asking ...
4
votes
2answers
708 views

Unable to set background image using python (2.7.3), bash and gnome3

#!/usr/bin/env python import os bashCommand = "gsettings set org.gnome.desktop.background picture-uri file:///home/malon/autowallpaperchanger/" + pic_name print bashCommand os.system(bashCommand) ...
7
votes
5answers
901 views

How are the programs in /bin directory compiled into a non-readable format?

I've noticed that most of my commands/programs in the /bin directory are compiled. I wish to duplicate this non-readable code format myself. Can someone tell me why and/or how these programs get this ...
1
vote
1answer
644 views

Bash script: Program with parameters as a single variable: command not found

I wrote the bash script below (called hdmi_output) and it's working in most parts as I expect it. For example, I run hdmi_output run firefox and Firefox is started on the external monitor. But ...
1
vote
1answer
1k views

Print specific dates in a specific format

I would like to write a bash script that prints out the date in the following format: 20120205_16 (year)(month)(day)_(24 hour) so the command to do this for the current date is: date ...
20
votes
2answers
5k views

How does this [t]ricky bracket expression in grep work?

I saw this one-liner recently: $ ps -ef | grep [f]irefox thorsen 16730 1 1 Jun19 ? 00:27:27 /usr/lib/firefox/firefox ... So it seems to return the list of processes with "firefox" ...
5
votes
2answers
864 views

What is this file: /usr/bin/[?

The name of the file is '[' . When I open it up in vi it looks like it's a copy of 'test'. It's owned by root.
2
votes
4answers
374 views

How do I find matching filenames in a directory listing?

I have bunch of ISO images in my hdd and I have their whole content listed inside a text file in the following format: <immage>.iso, <dir structure>/<filename>.<extension> ...
3
votes
2answers
481 views

rename files inside a folder in real time

Is there a way to rename files inside a folder as they're created? I could run a cron job every few seconds to do something like... find . -name "file.*" -exec sh -c 'echo mv "$1" "$(echo "$1" | sed ...
12
votes
4answers
5k views

Is bash scripting the same as shell scripting?

I'm very new to Ubuntu. I hear people say "shell scripting", "bash scripting". I wonder are they same? Or they are different? Thanks in advance.
0
votes
1answer
479 views

grep bash alias

I try to write grep alias exclude log files alias gr='grep -R --exclude=\*.{log,0,1,2,js} "$1" *' alias gr='grep -R --exclude=\*.{log,0,1,2,js} $1 *' Doesn't work correct I need to make something ...
3
votes
1answer
676 views

Script to periodically open a file at certain intervals?

I would like to write a script that would open a excel file periodically after certain intervals. How do I do it?
3
votes
2answers
790 views

Wget like utility to download all images in mysite.com/img/ directory

My access to the mysite.com/img/ directory is blocked. However all the images in that directory are in the form n.jpg where n is the nth image. My access to mysite.com/img/n.jpg is not blocked Is ...
3
votes
2answers
6k views

Creating a script to install software after a clean install?

I find myself moving between multiple new machines lately (new laptop, new computer at work, etc.). I want to create a bash script to install all the software I use. Ninite is not reach enough. I have ...
2
votes
1answer
3k views

automate transfer of tar files over FTP

Every day I have a script making .tar files of aparticualr directory. Once every day, I would like to transfere the new tar file made that day to a remote server over FTP. I would like to make this ...
2
votes
2answers
1k views

Write bash script which takes input from pipe

I am always typing things like this: cat some_list_of_elements.txt | awk '{print "\047"$1"\047"}' | paste -d, -s It takes a list of items from a file, wraps each in quotes, and merges them together ...
4
votes
2answers
3k views

How to make a bash script generate a new filename every time it's run?

I'd like to make a .tar file of a particular directory every day of the week. The way I'd like to do it is with a bash script making a tar file every day with crontab. I was wondering, is there a ...
1
vote
3answers
305 views

Advanced Terminal Emulation

Would there be a way to emulate the Desktop as a Terminal i.e. XTerm, so you can type in bash on the desktop? I want some form of window manager that does that exactly.
6
votes
3answers
7k views

using grep with pipe and ampersand to filter errors from find

I am using cygwin to find a file on the cygdrive. However I need to suppress the permission denied messages (otherwise the results get hidden in the error messages). The following command works: ...
3
votes
1answer
269 views

How do I set ubuntu to compress a series of folders , deleting the original after its been compressed?

I need to setup some kind of script to go through a set of folders, compressing each one, and only leaving the compressed copy of each. How can I do that?
4
votes
3answers
2k views

Is eval $(cat filename) the same as source filename?

Working on some bash functions, I didn't know source ... command, so I used eval $(cat ...) instead. Now I am wondering, whethe should I change every use of that, or is it just the same function? ...
3
votes
1answer
769 views

Autocomplete on .bash_aliases commands?

I have a whole bunch of aliased commands in .bash_aliases The most generic examples are alias apt-update="sudo apt-get update" alias apt-upgrade="sudo apt-get dist-upgrade" but then I also have ...
44
votes
4answers
8k views

How can I undo the last cd command?

Is there any way to jump back to the previous working directory after doing a cd to a different directory? My use-case is that I'm traversing a directory structure for a Java project, and I'm ...
1
vote
1answer
437 views

Asus Zenbook: how do I apply the bluetooth patch for 11.10?

Note: There is no need for a patch if you are running Ubuntu 12.04 I am following these instructions to recompile a kernel with working bluetooth for my Asus Zenbook UX31E. However, when typing ...
1
vote
2answers
660 views

Replacing blank character is not working inside script

In a shell script I tried to replace blank space by \n with this command echo -e $var |tr ' ' '\n' Outside the script it workd perfectly but inside there is no effect . This how i use in the ...
5
votes
2answers
912 views

Run auto-disper automatically on device wake/thaw

I'm using a Thinkpad W510 and constantly change locations. I'm using disper and auto-disper to change screen profiles (undocked; laptop screen + external screen; two external screens). I wanted to ...
0
votes
1answer
673 views

sed removes newline at EOF

I've tried using sed to replace an SELECT with BELECT in a file: sed 's/SELECT/BELECT/g' add_pixel.sql | diff - add_pixel.sql Gives me: 22c22 < BELECT MAX(ID) INTO max_id FROM pixels; --- ...
0
votes
3answers
2k views

Launch two processes and return first process to the foreground so it can be killed with ctrl-c

I am launching two processes in a bash script: run_webserver xdg-open http://$(hostname)/dev-environment The run_webserver is an ongoing process, so I need to be able to kill it with ...
3
votes
2answers
1k views

Find files/folders in folder except some specific folders

I'm trying to move all files from one folder to another, except some specific folders. I tried this to move all files except the .git, assets or build folders: find .. ! -regex ...
1
vote
2answers
2k views

Bash script to add/remove desktop launchers to Unity launcher?

I'm trying to write a script to setup my desktop environment after a fresh install. One thing I can't figure out is how to pin/unpin items to the Unity Launcher from a bash script. Any ideas?
2
votes
3answers
5k views

Shell Script to Run Commands to All Subdirectories

I am making a script to simplify my daily tasks. Everyday, I have to grep for a few things inside a company server. It was okay, however, now, they have segregated each object into sub directories. I ...
0
votes
2answers
1k views

How do I copy files that I just searched for via the command line?

Using Ubuntu 12.04 I need help on copying files that were returned from a search with grep . I have many pdf files, so to filter specific named files I am using General grep command as follows. ...
2
votes
3answers
610 views

How can I install and remove programs in one command line, and confirm only once?

When I install Ubuntu, the first thing I usually do is remove some programs and install some others. To get that done, I enter the following in a terminal: sudo apt-get remove applicationA ...
0
votes
1answer
515 views

How can I make a .deb file from a bash script? [duplicate]

Possible Duplicate: create a .deb Package from scripts or binaries I've made a bash script and stored it in /usr/local/bin. In the future, I'd like to get this bash script in /usr/local/bin ...
0
votes
2answers
3k views

unexpected EOF and end of document

I have been fiddling with this code for a few days. Mind you I am a beginner. I just want to get my script to be able to download a remote file, and scan MineCraft plugins. I got the scan plugins to ...
3
votes
3answers
303 views

After double-clicking a script on the desktop, show output in a terminal

I am trying to make a demo Virtual Machine. On the desktop, I have a script foo.sh and it outputs stdout to foo.log (e.g. with some command > foo.log) When I double click on the script, it ...
5
votes
3answers
7k views

Different ways of executing binaries and scripts

I've been using Linux for some time now and I've been searching for a complete overview of this but not found any. I just don't come to terms with all the different ways of executing scripts and ...
0
votes
2answers
3k views

edit ftp file via ubuntu terminal?

I'm connecting my website via $ ftp command. I want to edit some files via nano or gedit.But When I enter nano filename.php bash returns ?Invalid Command. How can i edit files via using ubuntu ...
4
votes
1answer
27k views

How to run Bash script as root with no password? [duplicate]

Possible Duplicate: How do I use sudo in my script without needing a password? I want to run a bash script as root with no password prompt. I tried visudo with no luck(your_username ...
1
vote
2answers
997 views

concatenation of two command in one single command

while read pos; do string1= echo $pos | cut -c 20-38 string2="=$pos" string3="$string1 $string2" echo "$string3" done < file This is the code of my script. I want to display the output in one ...