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

learn more… | top users | synonyms (1)

1
vote
1answer
637 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 ...
19
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
854 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
368 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
472 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
473 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
672 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
777 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
302 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
6k 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
744 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
7k 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
436 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
630 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
906 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
670 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
602 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
511 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
298 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
2k 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 ...
3
votes
1answer
26k 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
993 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 ...
2
votes
3answers
1k views

Is there a way suspend 12.04 using a bash command while keeping the password prompt?

I desire to suspend my Ubuntu 12.04 install with a bash script. The pm-suspend command will not prompt for a password when resumed. Is there a way to suspend my machine and have a password prompt when ...
1
vote
1answer
1k views

How can I recursively check folders with flac files for corruption?

Something caused to damage some of my flac files, and to find out which ones I need to rerip, I would like to get a list containing only the damaged files. How I do it now: Open a terminal in a ...
0
votes
1answer
2k views

How to execute a command on multiple files and redirct output to a different file depending on the name of the input file

I am trying to convert a batch of latex files using catdvi. The command I use for a single file is: catdvi -e 1 -U 1.dvi | sed -re "s/\[U\+2022\]/*/g" | sed -re "s/([^^[:space:]])\s+/\1 /g" > ...
0
votes
2answers
947 views

Batch command that reqiures output redirection

When I want to process a bunch of tex files, I use for f in *.tex; do latex "$f" ; done; What do I do when I need to redirect output to another file, like in case of catdvi? The following does not ...
1
vote
1answer
78 views

Graphical terminal misinterpreting input

I've been having this weird problem with typing commands into gnome-terminal. If the command takes up multiple screen lines and I use any backspaces and the stars are in proper alignment the command ...
2
votes
1answer
6k views

Bash for loop with range {#..#}

The {#..#} generate a sequence of numbers or chars, similarly to range() in Python. If I execute the command echo {1..5} in the command line I have: 1 2 3 4 5 Instead the following bash script ...
1
vote
1answer
206 views

bash doesn't use all directories from $PATH to search for executable

I thought, if you call a command in bash, all of the directories set in $PATH would be searched for this command. (running as root) $ clamscan ./ -bash: /usr/bin/clamscan: No such file or directory ...
2
votes
1answer
1k views

How do I flush output appended to a file by a bash function/loop in real-time?

My issue is that I have a function call it function1 which runs indefinitely. The function itself echo's "hello" every 1 second. Using the command: function1 >> temp.txt Every 1 second if I am to ...
4
votes
3answers
277 views

Search and replace within files

I found the following awesome little script at link $ find /home/bruno/old-friends -type f -exec sed -i 's/ugly/beautiful/g' {} \; But I really do not understand the final bit {} \; ...
0
votes
1answer
192 views

is there a way to autorun-on-DISconnect a USB external drive (U10.04)?

I have a small USB HD I've bought for doing daily backups, which has an encfs system on it. I've got an autorun script in the root that does a couple of things including mounting the enc-FS and that ...
3
votes
1answer
389 views

Script for filing call recordings into date folders

We have an IP PBX that is running Asterisk and is set by the manufacturer to delete call recordings after a certain time period. I am backing these up to an Ubuntu server using rsync so that we are ...
1
vote
1answer
3k views

XFCE suspend system command

When I click on the exit icon there is a suspend option. When I click this the computer suspends, which works really well. I want to create a custom key mapping on the suspend command XK86Sleep ...
11
votes
1answer
21k views

difference between gksudo and sudo? [duplicate]

Possible Duplicate: What is the difference between “gksudo nautilus” and “sudo nautilus”? I have tiny script that I want it to run on start-up, but it needs sudo ...