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

learn more… | top users | synonyms (1)

1
vote
3answers
349 views

how to check if stream is empty?

For example I want to execute : ps x | grep something | grep -v grep | somecommand I want to execute somecommand only if there is something running. How to do that ?
0
votes
1answer
59 views

What does ENDOFMENU do? [closed]

I have been given an example program, I am wondering what exactly the <<ENDOFMENU and ENDOFMENU does, won't it work the same if you leave it out and just use the while loop? #!/bin/sh echo ...
5
votes
4answers
2k views

How to rename files with count?

I have a directory like this: randomized_quad015.png randomized_quad030.png randomized_quad045.png randomized_quad060.png randomized_quad075.png randomized_quad090.png randomized_quad1005.png ...
4
votes
2answers
10k views

Bash script to remove line breaks?

I need a script that inputs a file and echos its contents with linebreaks removed - "word wrapped" so to speak. I've tried: #!/bin/bash find $HOME '$1' | while read line; do echo "${line}"; done ...
8
votes
6answers
61k views

Every command fails with “command not found” after changing .bash_profile?

I was updating my .bash_profile, and unfortunetly I made a few updates and now I am getting: env: bash: No such file or directory env: bash: No such file or directory env: bash: No such file or ...
0
votes
1answer
2k views

What is this PS1 variable doing in .bash_profile file?

Currently my terminal prompt looks like: blankman-MacBook-Pro:~ $ My .bash_profile has: export PS1="\[\033[36m\]\h:\W \[\033[33m\]\$(parse_git_branch)\[\033[00m\]\$(git config ...
1
vote
1answer
367 views

apt-get install - how to get report about failed installs?

I've created my script to install software on a new computer. Basically it includes lot's of apt get install <pkg name> -y lines. How can I get a short report about installs that has failed? ...
5
votes
3answers
8k views

Move running program to background in bash

If I'm running a program in bash, I can suspend it by pressing Ctrl+Z. If I want to leave the program running, I can then use the bg command. Is there some way to directly put the program in the ...
5
votes
2answers
2k views

How to diff two folders to multiple patch files

I'm not much of a unix guy so I'll just go ahead and ask: I have a following problem - two folders with plenty of subfolders. I need to diff them. I tried this: diff -drupN vanila_kernel_3.0.8 ...
0
votes
2answers
2k views

Autojump in 12.04 doesn't work

https://launchpad.net/ubuntu/+source/autojump I installed with apt-get, checked out the man page and added . /usr/share/autojump/autojump.sh to my .bashrc, like it says. When I cd around the ...
1
vote
2answers
311 views

Simultaneous commands

I'm trying to get bash to execute two commands simultaneously. I've read a little about job control, &, bg, fg, but the problem is that the command I want to run doesn't run properly in the bg. ...
0
votes
2answers
978 views

Running gedit in background

So I've got this working in a 10.04 ubuntu OS in bash where I can run: $ gedit app/file.rb bash opens that file with gedit but it is tied up. How can I make my earlier command equivalent to $ ...
2
votes
1answer
582 views

Setting the PATH in .profile works without exporting it, how?

the default .profile does not export PATH, still the PATH set there is available to all processes. How does that work?
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 ...
1
vote
1answer
585 views

How to fetch a image from online(http) and make it as a wallpaper using Ubuntu terminal

I need to change the background of my desktop in Ubuntu 12. 04 with a command in terminal, in order to make a script with bash. Does anyone know how to do it? but i want the image from internet... i ...
2
votes
1answer
407 views

Printing Checks from CLI or GUI

Looking for a program or a way to print onto my bank checks in Ubuntu. I don't want to use GNUCash or KMyMoney as those are bank register program's and it's too much work to open one of those each and ...
19
votes
3answers
4k views

How do I search a PDF file from command line?

I'm checking references of a paper and want to find the positions in the body where some paper (in the references list) is referenced. Is there a PDF editor which supports search via bash and extract ...
4
votes
1answer
297 views

Why Byobu custom status notification code fail to show in color?

The code below runs well in Bash and shows text with proper green background color but when I add it to the ~/.byobu/bin/ folder it shows the escape characters instead. Something like ...
13
votes
2answers
28k views

How Do I fetch only the numbers in grep?

I have file like this : other lines . . . blah blah blah (:34) I wish to find the occurrence of numbers in the above file. I came up with : grep [0-9] filename But that is printing the ...
26
votes
4answers
10k views

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

Is there a difference between kill -9 212121 and kill 212121
4
votes
2answers
12k views

bash script to login to webpage

I am trying to login into this page but I cannot for the life of me get it to work. I have to login to this site when i connect to my school's wifi in order to start a session. So far ive tried to ...
1
vote
1answer
2k views

How do I source a shell script for Node Version Manager?

Hi and thanks for looking! I am new to Linux/Ubuntu, but I have set up an Ubuntu box on which to run Node.js. I have had moderate success, but now I need to be able to easily upgrade my version of ...
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
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 ...
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
978 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 ...
9
votes
6answers
1k views

How to save GNOME Terminal contents with ANSI escape codes?

VT100 terminals have a relatively simple way to save terminal contents with escape codes to a file using Meta-p: XTerm.VT100.printAttributes: 2 XTerm.VT100.printerCommand: cat - > file ...
11
votes
2answers
3k views

Is there a difference between “.” and “source” in bash, after all?

I was looking for the difference between the "." and "source" builtin commands and a few sources (e.g., in this discussion, and the bash manpage) suggest that these are just the same. However, ...
0
votes
1answer
104 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
712 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) ...
3
votes
2answers
8k views

shopt works in command line, not found when run in a script

I'm writing a script to copy some files around, and trying to use shopt -s dotglob to enable cp to copy dotfiles like .jshint and whatnot. I can run shopt -s dotglob directly at a bash prompt with ...
6
votes
4answers
2k 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 ...
2
votes
3answers
16k views

Wubi Grub Prompt “Minimal BASH-like line editing is supported” [duplicate]

I just installed ubuntu today with WUBI. After installing, the first time I tried to boot it, it gave me a screen with this grub prompt: Minimal BASH-like line editing is supported. For the first ...
1
vote
1answer
647 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 ...
11
votes
4answers
29k views

How to round decimals using bc in bash?

A quick example of what I want using bash scripting: #!/bin/bash echo "Insert the price you want to calculate:" read float echo "This is the price without taxes:" echo "scale=2; $float/1.18" |bc -l ...
19
votes
4answers
15k views

How do I set up an email alert when a ssh login is successful?

Does anyone have a bash script that will email or notify someone in the case of a successful login to a ssh server? I want to be notified if anyone logs into my personal box. I'm using Ubuntu 12.04 ...
5
votes
2answers
872 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.
3
votes
2answers
486 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 ...
2
votes
4answers
377 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> ...
7
votes
5answers
906 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 ...
63
votes
6answers
117k views

How can I decode a base64 string from the command line?

I would like to write a bash script to decode a base64 string. For example I type decode QWxhZGRpbjpvcGVuIHNlc2FtZQ== and it prints Aladdin:open sesame and returns to the prompt. So far I have tried ...
0
votes
1answer
487 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 ...
2
votes
4answers
587 views

Why is the following bash command not working properly?

I have the following bash command: $(ls -l /var/ | grep www) > cat folder_exists but it is not working properly. What I hope to achieve is a command, that checks to see if there is a www folder ...
3
votes
1answer
678 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?
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 ...
2
votes
3answers
3k views

Desktop file for bash script

I have a .desktop file for a bash script, but when I launch the .desktop file nothing happens except that a terminal window is shown for half a second. If I run the bash script directly (without the ...
8
votes
4answers
3k views

How can I play a song in the background via my command line?

I have installed play : sudo apt-get install sox libsox-fmt-mp3 I can now play my audio files like this : play Desktop/SONGS/01\ -\ Oh\ Baby\ Girl.mp3 Since I'm learning shell, I wish I could ...
3
votes
1answer
3k views

Ubuntu alias not applied in bashrc

I am under Ubuntu 12.04 LTS. I have added such line to ~/.bashrc alias myconf="sudo nano /opt/nginx/conf/sites-available/efiling" I tried with single quotes too: alias myconf='sudo nano ...
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 ...