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

learn more… | top users | synonyms (1)

3
votes
2answers
13k views

Read file into array

How can I read file in shell script , then assign each line to an variable that i can use later ,,,(am thinking in way to load an default setting from file) i already try : process (){ } FILE='' ...
2
votes
3answers
389 views

What other bash variables are available during execution such as $USER that can assist on my script?

This is related to question 19245, in that one of the responders answered the question in an awesome way, and very VERY clear to any newbie. Now here is a question that i can't seem to figure. i ...
1
vote
3answers
399 views

Script to move pictures

How can I write a script that will move all .png .svg .gif files from /home/eric/Desktop to /usr/share/icons?
1
vote
1answer
2k views

Path not setting up for a setup

I am unable to add path of my omnet bin directory for the installation. During the installation i go to the omnet directory and enter ./configure which gives me the following errors WARNING: your ...
1
vote
1answer
555 views

Display number of hours since a specific time in bash

I have a command that outputs a single date in whatever format I please. Now I need a simple way of calculating (with bash) how many hours have passed since that date (default is yyyy-mm-dd hh:mm). ...
3
votes
1answer
297 views

link key to a bash script

I'm trying to link a button (now without function) to a bash script that I have made on UBUNTU. I'm using a clevo W150HNM/Sager NP5160 I want to use 1 or 4 for this(see photo on ...
2
votes
4answers
197 views

Find and bash problems in recent Ubuntu versions

I've been having a problem the last six months or so when combining searches in bash. The exact example is related to Python programming but would apply to any kind of detection/manipulation. Suppose ...
3
votes
1answer
1k views

cannot insert backslash with bash, python, works fine with csh, idle

I have a strange problem with inserting backslashes (Ubuntu 10.10 and 11.04, the upgrade changed nothing). The key combination on my keyboard (Swedish Thinkpad T400) is AltGr + ?. However, this seems ...
0
votes
2answers
939 views

Shell tweak to show current path in addition

I'm using ubuntu 10.10 and now I got in the shell something like that: machine1user@mylinux:~: how can i change it to machine1user@mylinux:/my/current/path :~: ?
2
votes
3answers
523 views

Integer operators in bash

How can I use ++, +=, *=, etc operators in bash script. Examples please. Example in C++: int a = 7; a = ++a + ++a; printf("%d", a);
8
votes
1answer
3k views

Why does /bin/sh point to /bin/dash and not /bin/bash?

As far as I understand bash is the default shell in Ubuntu, so why does /bin/sh point to /bin/dash?
0
votes
1answer
168 views

What command runs when I SSH into a server?

When I SSH into a server, I see the MOTD then I am in BASH. What command is running that takes care of displaying the MOTD and then starts the shell?
0
votes
2answers
4k views

Copy file to dir using wildcards or regular expression in destination?

I want execute this cp debian.master/abi/2.6.38*/amd64/generic debian.master/abi/2.6.38*/amd64/core2 but bash gives error in second *: cp: cannot create regular file ...
1
vote
2answers
601 views

Add Progress Bar

I would like to include a zenity progress bar for this part of my script: zenity --question --title "GUI" --text "Sync Music to iPad?" if [[ $? == 0 ]] ; then scp -r "$FOLDER" ...
1
vote
1answer
1k views

Bash: change environment temporarily

I am using a dev tool which supplies a script that sets environment variables. If I source the script the environment is modified for the duration of the bash secession. In order to revert the changes ...
6
votes
3answers
2k views

Why does my shell script hang without the .sh extension?

I created a shell script /usr/local/bin/suspend with the following content: #! /bin/sh # Take an optional delay parameter if [ "$#" -gt "0" ]; then sleep "$1" fi # Put the system to sleep ...
8
votes
3answers
7k views

Apt-get install multiple packages without stopping

I am making a bash script that installs various packages using apt-get install. However, I notice that if there is a line that says: sudo apt-get install package1 package2 package3 and either of ...
0
votes
1answer
197 views

Weird Stuff in Terminal When I Hit Tab

For some reason, today, everytime I hit tab in the terminal this shows up: cat bash: warning: setlocale: LC_CTYPE: cannot change locale (en_CA) Display all 150 possibilities? (y or n) This ...
0
votes
1answer
917 views

My SSH tunnels get interrupted because the host machine falls asleep. Bug or Feature?

My gnome-power preference is set to automatically sleep after 30 minutes of inactivity. Apparently it thinks that a ssh connection is not a valid reason to keep it alive. Is this a feature or a bug? I ...
0
votes
3answers
2k views

How to change directory at the end of a bash script?

In my .bashrc: function rnew { $HOME/.dotfiles/railsnewapp.sh $1; } Essentially, I call rnew from any directory, and it creates a directory in ~/code/appname, installs Rails into it, and then I ...
3
votes
1answer
13k views

How to redirect output to screen as well as a file in a yet-to-be-created directory?

My aim is to log all output from a script into a directory that the script is going to create. For example, I have: ~/.abc.sh: #! /bin/bash rails new myapp When I run... cd ~/code . ~/.abc.sh ...
5
votes
1answer
8k views

Extracting from a tar file - Default behavior: overwrite or keep?

In the documentation, I read that tar has the following options when extracting files from a tarball: -k, --keep-old-files don't replace existing files when extracting --overwrite ...
4
votes
4answers
522 views

How to create bash file and allow it to accept an argument from the terminal?

In recall for nostalgic feelings, I've remembered the .bat files on DOS. :) Here's the thing: Each time I need to generate a documentation for a given web application I have to: sudo phpdoc -o ...
0
votes
2answers
278 views

whats wrong with this zenity code?

whats wrong with this code? #!/bin/bash ARCH=$(uname -m) if ["$ARCH" = "i686"]; then zenity --info --title="Architechture Checker" --text="Your Architechture is 32-Bit" if ["$ARCH" = "x86_64"];then ...
3
votes
1answer
558 views

How to automatically graph the output of a shell function

I do a lot of video editing and processing, and spend a lot of time looking at the output of command line programs like ffmpeg. Ffmpeg produces a regular output of the form frame=1234 fps=80 q=-1.0 ...
2
votes
3answers
319 views

Can I boot straight into bash from a USB drive installation?

I need to boot from a USB drive installation of Ubuntu 10.10 to do some maintenance on an older machine, and I don't feel like waiting for five minutes for the gnome to log me in. Is there a boot ...
0
votes
1answer
210 views

Is there a better (closer to home row on keyboard) shortcut for the home directory in bash than tilde?

I don't like reaching for the tilde ~ key so often when I'm specifying file and program paths relative to the user home directory on the command line. Does anyone have any tips for cutting the number ...
2
votes
1answer
197 views

Extra dash insertion when trying to run tar

I have a really weird issue where I'm getting an extra - insertion on tar: # tar -zxvf mod_wsgi-3.3.tar.gz /bin/tar: unrecognized option '--zxvf' Try `tar --help' or `tar --usage' for more ...
0
votes
3answers
209 views

variables in bash

for i in *.jpg do j = '$i | cut -d . -f 1' convert $i $j".png" done temp.sh: line 3: j: command not found I know about mogrify, just wanted to know how to get variables done in bash.
7
votes
2answers
5k views

How to find the version of an Ubuntu machine remotely?

I have more than 60 to 80 systems running Ubuntu. Some of them are with version 8.04 and some of them are with latest version 10.10. Now we are in the process of upgrading all older Ubuntu version to ...
1
vote
1answer
972 views

Executing a Super-user command through .bashrc

Is it possible to execute a super-user command in .bashrc? And if so, how? It would save me having to execute "sudo /opt/lampp/lampp start" on each startup. I've considered using the LAMP stack from ...
5
votes
2answers
624 views

guake with zsh doesn't start

I changed guake to use /bin/zsh from /bin/bash. now it doesnt start. by start, i mean that when click the shortcut key, guake just pops up for a second, and then disappears. I changed the default ...
1
vote
3answers
2k views

A problem with Bash script

I want to write a simple script to detect a file created by Windows virus. Usually it creates an .exe file, with the same name, as the directory it drops. Here is the script. It only works, if the ...
26
votes
5answers
4k views

Removing folder named ~

This is the output of ls -l ls -l total 53484 drwxr-xr-x 3 root root 4096 2011-02-10 05:59 ~ -rw-r--r-- 1 root root 54313810 2011-02-13 05:09 jobs.jar -rw-r--r-- 1 root root 384035 2011-02-15 ...
0
votes
2answers
465 views

Replace IP address within a string

I'd like to change the IP address in this string with some user input: rmi.sceduling.service.url=rmi\://192.168.0.19\:1199/ScedulingService The code should also work if there is no address: ...
2
votes
1answer
6k views

Where is bashrc profile for root?

I believe the question says it all. Also if it doesn't exist where do I create it. Ubuntu 10.04
5
votes
1answer
1k views

Command to determine whether a fullscreen application is running?

I have a small shell script that plays a little jingle and displays a notification whenever I get a new email. The problem is that this shell script can get invoked anytime - including when I'm ...
1
vote
3answers
6k views

Replace string in bash script

I tried the following command in my script: find=grep "$jasper" jasperreports.properties | awk -F"reports/" '{print $2}' Example output: maps I want to change this output to something else, e.g. ...
4
votes
2answers
361 views

Combine Two Commands In a Script

I want to put two commands together I need the script to login: ssh root@192.168.0.188 Then I need to the script to run (while logged in to root@192.168.0.188 via ssh ): find ...
5
votes
1answer
2k views

How to execute a script as super user first checking the user and getting pass from askpass if not super user

thers a similar question out there How can I determine whether a shell-script runs as root or not? I have the same doubt with different result Is it possible to, within the BASH script prior to ...
3
votes
4answers
497 views

OS evaluate in bash script

i was thinking in way that before run my script , evaluate which operating system that user use ubuntu or solaris , am using this because there is some differences in command option in each OS ...
4
votes
2answers
7k views
1
vote
1answer
2k views

How to get nicer error-messages in this bash-script?

I'm trying to catch any error when run a command in order to write a log-file / report I've tried this code: function valid (){ if [ $? -eq 0 ]; then echo "$var1" ": status : OK" ...
4
votes
1answer
552 views

Problem manipulating text using grep

I want to search for a line that contains log4j and take 7 lines before and 3 lines after the match. grep -B7 -A3 "log4j" web.xml After that I want to add comment tags before this paragraph and ...
2
votes
1answer
466 views

Script to download music and transfer to Ipod?

I need help making a script that would do this This is what I would do manually in terminal (I will be using the .getmusic script from 360 percents to download myspace music): cd /home/eric/Music ...
2
votes
2answers
2k views

Sed problem in a Bash script

I'm having a problem using the sed command . I'm trying to write a bash script that does the following : search for the line that contain :@ then save the line that contained :@ and replace it ...
2
votes
1answer
275 views

Anomaly with bash PS1 definition

My root and admin user both have the same .bashrc file. The prompt section of the .bashrc is the following: if [ "$color_prompt" = yes ]; then ...
0
votes
1answer
2k views

How do you unset an environmental variable using a script?

If I have HTTP_PROXY defined in default my environment (by ~/.bash_profile), how can I unset the variable from a script? I know that I can do unset HTTP_PROXY from the command line, but if I try to ...
2
votes
1answer
6k views

Run simple bash script to start applications at login

I want to run a simple bash script automatically when I log in. For example #!/bin/bash echo "start spotify" gnome-terminal -e spotify --title spotify When I run this command, one gnome-terminal ...
18
votes
2answers
14k views

How to grep 2 or 3 lines, one containing the text I want, and the others just below it?

This is a snapshot of error log: 06:16:29,933 ERROR EmailRMManager$:45 - Exception In get Message com.rabbitmq.client.AlreadyClosedException: clean connection shutdown; reason: Attempt to use closed ...