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

learn more… | top users | synonyms (1)

2
votes
2answers
4k views

Problem with crontab, script runs when executed from command

this is my cron entry: */5 * * * * /home/user/scripts/backupDB.sh && echo "Backup Successful: $(date)" >> /home/user/tmp/mybackup.log This is the script that is called: #!/bin/sh ...
25
votes
5answers
34k views

How do I get long command lines to wrap to the next line?

Something I have noticed in Ubuntu for a long time that has been frustrating to me is when I am typing a command at the command line that gets longer (wider) than the terminal width, instead of ...
4
votes
2answers
262 views

Bash keybindings that match those of gedit?

I want to have the same keybindings in gedit and in bash. Namely all the selections, also cut, copy and paste. I know there are some important ones that are already taken (Ctrl+C, Ctrl+W, etc), ...
3
votes
1answer
1k views

How to compute PID cpu load?

Please help me to find a reliable way to compute (in a bash script) a jboss PID cpu load. To be specific, I don't know how to aggregate /proc/[pid]/stat fields to obtain the load a specific process ...
34
votes
6answers
6k views

Is there a difference between the '&&' and ';' symbols in a standard BASH terminal?

They seem to both signal BASH to commence with another command following the symbols but is there a distinct difference?
1
vote
1answer
1k views

.bash_login not executing

I've put a .bash_login file in my $HOME-directory but it doesn't execute. I've also tried .bash_profile but also doesn't work. There are also .profile .bash_history .bash_logout Any idea? I'm ...
5
votes
2answers
3k views

always prompt the user before executing a command in the shell

Is there a utility that always prompts the user for confirmation before executing a command similar to the way sudo asks for password?
0
votes
4answers
657 views

Why don't those winepath commands work?

I tried code from this question and for some reason they do not work, why and how to fix them? a@ubuntu:~$ echo "#!/bin/sh" > ~/bin/run_linx_program bash: !/bin/sh": event not found a@ubuntu:~$ ...
6
votes
2answers
3k views

Can I use standard tools to get the full name of a process, when its name has embedded spaces?

I understand that it may be a rare situation for an executable to have spaces in it, but it could happen. An example may be the best explanation.. Using standard tools, I want to determine the ...
5
votes
2answers
899 views

How do I use bash's “<<” operator?

I know bash has a >> operator, to append output to files, but what is the use of the << operator?
23
votes
1answer
53k views

Command to append line to a text file without opening an editor

Assuming i have a line that i want to add to a file without opening an editor. How could i append this line alias list='ls -cl --group-directories-first' to this file config.fish
4
votes
1answer
1k views

Bash script: How to execute commands consecutively without waiting for the previous one?

In a bash script that execute 2 commands like this #!/bin/bash gedit nautilus Nautilus starts not before gedit is closed? How can i avoid this?
13
votes
3answers
4k views

How to debug bash script?

Is there any way to debug bash script without using echo and logging? I'm talking about using breakpoints and stuff like that.
2
votes
3answers
386 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 ...
5
votes
4answers
26k views

sudo: source: command not found

I've been updating some of the default profile for bash, and saw from the tutorials I was following that I could reload the new profile with the new environment settings by using: source ...
3
votes
2answers
3k views

Is there a way to suspend/sleep via bash?

I have to get nine 46" LCD monitors (running Windows) to suspend/sleep at 8pm and wake at 8am every morning. It's been a bit of a mess trying to get the commands working, including the privileges. ...
5
votes
2answers
672 views

How do the environments of a standard Terminal command-line and a bash script differ?

I know there is something different about the environment of the Terminal command-line and the environment in a bash script, but I don't know what that difference is... Here is the example which ...
1
vote
3answers
598 views

Why does printf report an error on all but three (ASCII-range) Unicode Codepoints, yet is fine with all others?

The 'printf' I refer to is the standard-issue "program" (not the built-in): /usr/bin/printf I was testing printf out as a viable method of convert a Unicode Codepoint Hex-literal into its Unicoder ...
2
votes
4answers
4k views

Script for an incremental file system backup

I'd like to run the following incomplete script weekly in as a cron job to backup my home directory to an external drive mounted as /mnt/backups #!/bin/bash # TIMEDATE=$(date +%b-%d-%Y-%k:%M) ...
5
votes
5answers
3k views

Concatenating several .mp3 files into one .mp3

As it was suggested here I am using cat command to concatenate several .mp3 files into one .mp3 file. Imagine, I have following .mp3 files in the current folder: 001001.mp3 001002.mp3 001003.mp3 ...
16
votes
6answers
8k views

Differences between doublequotes “ ”, singlequotes ' ' and backticks ´ ´ on commandline?

I often see tutorials on the web or posts on this site which make heavy use of the following characters at the command line. Often it seems that they are used for pretty similar purposes. What are the ...
5
votes
5answers
5k views

How to reinitialize a terminal window instead of closing it and starting a new one?

When i make some changes to the shell/bash behavior. I.e. set up an alias, what quick way does exist to reinitalize the terminal window instead of closing and open a new open? Perhaps a commandline ...
2
votes
2answers
3k views

Differences between fish and bash to pass commandline arguments to alias functions?

From the answers to my other question here i learned about the possibility to pass commandline arguments to a alias function in Bash. In Fish i can edit an alias by editing the file config.fish in ...
1
vote
1answer
9k views

How do I enable a user to sudo without password?

I have a php script with this: <?php #echo exec('whoami'); $output = shell_exec('bash /usr/local/svn/bash_repo/make-live'); echo "$output"; ?> The make-live script contains this: ...
1
vote
1answer
164 views

KMenu & shell script

I'm trying to make a very small shell script with a simple command and add it up to the KMenu. Well, thing is that once it launches the shell script, it closes it fast and I want to leave it open ...
5
votes
3answers
823 views

Why is this by passing the SUDO password?

I have a bash script I am using to automate a SVN checkout. The contents of the file were: #!/bin/bash cd /var/www-cake sudo svn checkout file:///usr/local/svn/bash_repo/repo/ Then when I double ...
4
votes
3answers
1k views

How to change a particular path from the environment variable PATH?

I incorrectly declared a variable, and now it has two forward slashes in it. How do I unset/correct it? PATH=...ols-1.3-62308//bin:/bin Thanks.
3
votes
4answers
218 views

Is there a way to take influence on behavior of bash history?

In terminal the bash history is often helpful when you are searching for a command-line that you already used. But is there a way to influence the behavior of the bash history (i.e. which commands are ...
1
vote
1answer
294 views

Passing sed to a temporary variable

I am trying to bulk change some files in bash that have spaces and unwanted endings to their extension. For example from abc.pdf.!ut.!ut to abc.pdf I will show whole progress in case I made ...
4
votes
2answers
3k views

How to load a `zenity` List Dialog with space-embedded data from `ls`?

I'm having problems loading a zenity List Dialog when the data contains spaces. It is straight-forward when there are no spaces in the listed data, but I don't know of a simple/standard method for ...
1
vote
1answer
2k views

Pipe error with bash script called from python

I'm trying to run a shell script inside some python code, but I keep getting an error message. Python script (test.py): import os f = os.popen('/home/test/Downloads/record.sh') f.close() ...
11
votes
5answers
8k views

trim the terminal command prompt working directory

When using the terminal in a deep folder structure sometimes the prompt can take up most of the line. Is there any way in which I can trim the working directory? I know I can do PS1="\W >" to only ...
53
votes
6answers
92k views

How do I create a permanent Bash alias?

I would like to create an alias to rm command in order to have a confirmation message after executing this command. So I am creating an alias like this alias rm='rm -i'. But as far as I know this is a ...
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 ...
3
votes
5answers
1k views

Overwrote /bin/bash, after replacing still broken

I use Ubuntu 10.10. I abused sudo and accidentally overwrote my /bin/bash file via a typo, so I booted to the LiveCD and restored my copy with a "good" one from the Ubuntu 10.10 LiveOS. This did not ...
7
votes
3answers
14k views

I can't find .bash_profile

I am trying to learn how to tweak my shell in the file but can't seems to find the file in my home directory or in /etc/profile. Is there any other file I need to search for, or am I expected to ...
52
votes
4answers
24k views

Hide current working directory in terminal

As a default, the terminal prompt shows something like: user@system:/folder1/folder2/folder3/folder4$ the deeper you go into the filesystem, the less space is left for typing in commands. Can I ...
3
votes
3answers
421 views

How can I activate a Panel-icon via a script (or get its screen co-ordinates; to click it)?

This question is in the context of Lucid 10.04 desktop (ie. no Unity). I do most screen navigation via the keyboard (not the mouse), so I'm looking for a script solution to re-activating an app which ...
13
votes
3answers
3k views

Showing a “cowsay” fortune in every new terminal session

I wish to display a cowsay message in every terminal window. The command I use is fortune | cowsay Any ideas how to make it appear whenever I start a new terminal session?
10
votes
1answer
5k views

Displaying a new line on the prompt

I wish to add a new line on every prompt. Instead of the cursor showing on the line as name@machine:~$ _, I want it to be on the next line, like as: name@machine:~$ _ Thanks.
7
votes
2answers
2k 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. ...
0
votes
1answer
3k views

Bash: if condition to check if actual date exists as string in file?

In a file i have a string like this which is the date of today Sa 4. Dez Date format is like this stringtoday=`date +%Y-%m` now i wanna use a if condition to check if the date of today exists in ...
6
votes
2answers
2k views

Execute Bash script at startup, but only once a day?

I have a bash script that should be executed on ubuntu startup after boot. The problem is the script should be only executed once a day. So when the script recognizes that it already has been ...
5
votes
4answers
6k views

Overwrite previous output in Bash instead of appending it

For a bash timer i use this code: #!/bin/bash sek=60 echo "60 Seconds Wait!" echo -n "One Moment please " while [ $sek -ge 1 ] do echo -n "$sek " sleep 1 sek=$[$sek-1] done echo echo "ready!" ...
1
vote
2answers
2k views

Is there a way to start a bash script after boot only when wlan0 is connected

i want to start a bash script in ubuntu after boot. But the script should run first after wlan0 device is connected to my wifi. How can i achieve this?
20
votes
6answers
6k views

How can I create an alias for cd and ls?

I frequently run the ls command after running the cd command. How can I create an alias (like cs) for this operation?
20
votes
5answers
8k views

How to avoid duplicate entries in .bash_history

The same command is listed in my history again and again. How can I avoid this? I know it's possible via HISTCONTROL but I haven't found the right way.
15
votes
3answers
7k views

How can a script check if it's being run as root?

I'm writing a simple bash script, but I need it to check whether it's being run as root or not. I know there's probably a very simple way to do that, but I have no idea how. Just to be clear: What's ...
18
votes
5answers
2k views

Repercussions to sharing .bashrc across machines with Dropbox?

I work on a lot of different machines, all running Ubuntu (not always the same version). I have some really basic customizations to my prompt I would like to have available on all machines. I ...
13
votes
5answers
636 views

Teaching bash to beginners who only used Windows [closed]

I'm supposed to give an introduction to using the shell (i.e. bash) to total beginners. Which is the most basic/useful stuff I can teach someone within 1 1/2 hours without demanding too much? Here ...