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

learn more… | top users | synonyms (1)

1
vote
1answer
92 views

Get disk utilization by file-type?

Is there a way to get a break down of a disk (or directory) utilization based upon file-type from the command line? I guess I could write a bash script to find+du based upon a few known file-types, ...
0
votes
1answer
250 views

Line gets overwritten instead of continuing on same line

I have a problem with the bash prompt. When I type a command that exceeds the length of the width of the screen it continues on the same line and overwrites what I have written, and then continues on ...
2
votes
2answers
528 views

Why “cd ..” doesn't work in this if

pwd | grep 'database$' if [ "$?" = 0 ]; then echo "has db" cd .. cd .. echo "after has db" fi after I execute it I see has db after has db and I'm still in the same dir, how to fix it?
2
votes
4answers
3k views

Recursively rename files - oneliner preferably

I found this answer how do i... but it simply doesn't work - it did not rename any file for unknown to me reason Before I started to search around I thought that it should be easy task even for ...
20
votes
3answers
14k views

Bash history handling with multiple terminals

I use mainly Terminator, and it's usually opened with 3 split terminal windows. I also use Gnome terminal for various reasons. I'm wondering how is bash history handled in this case as I sometimes ...
9
votes
6answers
3k views

How do I sort by human readable sizes numerically?

for example I have command that shows how much space folder takes du folder | sort -n it works great, however I would like to have human readable form du -h folder however if I do that than I ...
2
votes
5answers
677 views

How to grep whole manual?

I can do for example man cp | grep verbose to findout if cp man has word "verbose", how can I do something like (pseudo-code) man * | grep copy to find out what command to use for coping?
2
votes
1answer
2k views

Applying chgrp “apache” to entire directory failed

I've been tried to change group of the whole directory with code example below [bash terminal on ubuntu 11.10]: chgrp apache -R ./test1 but failed and said : chgrp: invalid group: `apache' user ...
2
votes
1answer
2k views

Typing commands into a terminal always returns “-bash: /usr/bin/python: is a directory”

I think I messed something up on my Ubuntu server while trying to upgrade to Python 2.7.2. Every time I type in a command that doesn't have a response, the default from bash is this: -bash: ...
1
vote
1answer
404 views

My terminal prompt PS1 mixed up

By the way I'm on a Mac OS X but I'm connected to an Ubuntu Server. Yesterday I installed a module for node.js(after a hour I deleted it) which asked me to add something to the .bashrc file and now ...
2
votes
7answers
5k views

How to enter every directory in current path and execute script

I want to enter every directory retuned by ls command and execute script. I tried this (and many other things), but it just does not work ls | awk '{print $1" && pwd"}' | xargs cd How to ...
5
votes
3answers
2k views

Need help with bash checking if computer uptime is greater than 5 minutes

I have an bash script that runs on a every minute cron. It checks to see if a necessary program is running and starts it if it is not. Occasionally it will run before the user has actually autologged ...
1
vote
1answer
8k views

How to get line number from grep?

the fallowing grep grep -r -e -n coll * will display fullpath/filename: <tag-name>coll</tag-name> I would like to know what line has the fallowing text, I tried adding -n, but it ...
3
votes
3answers
4k views

How to find text and replace that line if exists with terminal otherwise just append line to end

I want to put in sudo gedit /etc/sysctl.conf the one line vm.swappiness=10 which I sometimes change. By default this line doesnt exist so I use echo "vm.swappiness=10" | sudo tee -a /etc/sysctl.conf. ...
3
votes
2answers
1k views

How to create daily job without write access to /etc?

I don't have write permissions to /etc and its sub folders, but even do I would like to have bash script that is executed every morning. How to set it up? also when i type cron in command line I get ...
1
vote
0answers
74 views

How to disconnect modem when postfix queue gets empty? [closed]

in /etc/ppp/ip-up.d/script I have the following that runs fetchmail when the ppp0 interface is up (connected) and when it finish the modem ends internet conection automatically. #!/bin/sh ...
20
votes
2answers
90k views

how to use variables in SED?

I try the fallowing code and it does nothing var1=QQ sed -i 's/$var1/ZZ/g' $file However this code replaces QQ with ZZ sed -i 's/QQ/ZZ/g' $file how to use variables in SED?
6
votes
2answers
13k views

How to escape file path in SED?

I would like to replace $fileWithPath in $file, however this not works because (I think) path is not escaped. how to escape it? sed -i 's/${fileWithPath}/HAHA/g' $file
2
votes
1answer
263 views

How to make tail -f show time when line was appended?

I'd like to know the time when line was appended when file is being tail -f'ed. Is it possible to configure tail to do something like that?
0
votes
2answers
574 views

Redirection Doesn't Work

I want to put my program's output into a file. I keyed in the following : ./prog > log 2>&1 But there is nothing in the file "log". I am using the Ubuntu 11.10 and the default shell is ...
0
votes
2answers
1k views

How to append text to file every morning?

I would like to append current date to text file every morning at 7am. if the computer is turned off I would like it to be executed after its turned on.
2
votes
3answers
14k views

How to execute script in different directory?

I tried this ./home/user/scripts/someScript but it doesn't work No such file or directory any ideas?
4
votes
4answers
564 views

How to make script support file:/// notation?

When I copy any file and paste it in console or text editos it is passed as file:///home/user/path/file when I pass it to script it is not found What is the easiest way to convert that to ...
0
votes
3answers
785 views

Help me to add line to file password /etc/shadow

when I try to add line inside /etc/shadow: echo -e "admin234:!!:0:0:99999:7:::" >> /etc/shadow 1 2 3 The console show this message: -bash: 0: unrecognized history modifier or ...
0
votes
1answer
125 views

help me problem in my shell script

I need back from 2 or 3 to 1 after print error ?? 1 echo -e "program set defulte home dirctory /home/admin/$un" echo -e "DO you want use defulte home dirctory? Yes=1 & NO=2" ...
6
votes
4answers
7k views

How to add an extension to all files via terminal

I would like to add the .zip extension to all files. I tried this, however it does not work: ls | awk '{print $1 " " $1".zip"}' | xargs mv -f
1
vote
1answer
231 views

bash text processing and error message

for example I have this script that kills firefox ps x | grep firefox | grep -v grep | awk '{print $1}'| xargs kill -9 but when there is no firefox running it spits out: Usage: kill pid ... ...
0
votes
1answer
15k views

why syntax error near unexpected token ' fi '

#!/bin/bash # # # # echo -e "please insert user name :" read un echo "$un" len=${#un} echo "$len" ze=0 te=10 if [ "$len" -eq "$ze" ] than echo "no argument" exit fi if [ "$len" -ge ...
1
vote
1answer
405 views

shell script to insert line into /etc/passwd , /etc/shadow ,/etc/group and save it

Can anyone help me to add one line to any file from this: /etc/passwd , /etc/shadow ,/etc/group exp; username:!!: …. add to /etc/shadow by shell script without vi program
19
votes
5answers
1k views

How do I teach bash in Ubuntu some curse words?

When bash encounters an unknown command(word?) it does this : The program 'hello' can be found in the following packages: * hello * hello-debhelper Try: sudo apt-get install <selected ...
3
votes
1answer
570 views

How to compare zip files' contents?

Is there any tool to compare zips by content? maybe some krusader addon or command-line magic?
2
votes
5answers
15k views

How to modify “/etc/bash.bashrc”? It is read only?

Trying to modify /etc/bash.bashrc I get an error: $ echo "my edit" >> /etc/bash.bashrc bash: /etc/bash.bashrc: Permission denied ls -ll /etc/bash.bashrc shows: -rw-r--r-- 1 root root 1975 ...
19
votes
2answers
820 views

Why does it take so long for Ubuntu to say “command not found”

For some reason, with my setup, it can take Ubuntu several seconds to respond with "command not found" when I accidentally typo a command. Why does it take so long? Is there any way to shorten the ...
18
votes
8answers
43k views

How to remove all files and subdirectories in a directory WITHOUT deleting the directory in bash?

Is there a command to remove all files and subdirectories in a directory WITHOUT deleting the directory? For example if I have directory "dontDeleteMe" with subdirectories "1", "2", "3" and each ...
4
votes
1answer
4k views

When you run `update-rc.d myscript default` - what is called on startup/shutdown?

What gets called on startup/shutdown when you run update-rc.d myscript default? Docs seem fuzzy, I want concrete. I am guessing that this happens: At startup (specifically at entry to runlevel 2, ...
2
votes
2answers
9k views

How to write an init script that will execute an existing start script?

I'm trying to understand the init process. I have a script which launches 3 background processes (2 shell scripts and a java app). It works just fine from the command line. I'd like to execute that ...
2
votes
1answer
784 views

How to run script at shutdown? [duplicate]

How can I make a bash script run only at shutdown? I have searched for it and keep coming up empty handed. I would be fine with either a link or an explanation to how to do it.
6
votes
2answers
6k views

What is my crontab -e local file path? I want to set it via BASH script

In my Ubuntu, my username is "meuser". When i do crontab -e, i can setup my rules. But instead of doing it with crontab -e, how can i do it directly to a file? Which file i cant modify?
1
vote
1answer
333 views

How to interpolate a variable immediately after a `$` or `\$` in the bash prompt?

I am using this function: function test(){ local var="hello" PS1="\u\$$var" } The output I am trying to get from the function is john$hello. But what I get is just john. If I add a space ...
0
votes
2answers
671 views

Problem using `sed` to colorize `ls` output (Tenth back-reference `\10` not working)

I had asked this question a while back: Is it possible to colorize permissions-part of the output of ls? While the accepted answer in that question is OK, I now want to do the same thing without ...
17
votes
3answers
2k views

how to get bash to stop escaping $ during tab-completion?

I have this on the command line: ln -sf $PWD/wine- and then I hit tab to complete the filename. In earlier versions of Ubuntu, this worked just fine to complete the wine- filename (and as a ...
2
votes
1answer
120 views

What happens when I run ln -s pear /tmp/pear-build-`whoami`

I have read this interesting post regarding the installation of php-mongo driver not writeable by the current user mkdir pear ln -s pear /tmp/pear-build-`whoami` /usr/bin/pear config-set cache_dir ...
2
votes
2answers
2k views

How to run an executable bash script on Kubuntu?

I have recently changed my OS from Ubuntu 11.04 to Kubuntu 10.04 but don't know how to get my executable bash scripts to run on Kubuntu. On Ubuntu all I did was click on the text file and I was given ...
1
vote
1answer
385 views

gdialog cannot output variable

copied='cp -v *SNAPSHOT.jar /home/user/folder' $copied prints information about copied files however gdialog --title "done" --clear --yesno "done $copied" 15 60 shows command that was executed, ...
2
votes
1answer
899 views

Upstart scripting: Start service and immediately run another command

Here is my current Upstart script I've placed at /etc/init/redis.conf: description "redis server" start on runlevel [2345] stop on shutdown exec sudo /opt/redis/redis-server /opt/redis/redis.conf ...
31
votes
9answers
25k views

How do I restrict my kids' computing time?

Access to our computer (not only to the internet) needs to be restricted for the accounts of my kids (7, 8) until they are old enough to manage this by themselves. Until then we need to be able to ...
1
vote
1answer
665 views

Running program on startup

I wrote a program in Bash, and now I want to run it on startup for all users so that nobody can cancel it, except for root. How can I do it?
28
votes
4answers
9k views

How to create script with auto-complete?

When I use program like svn and I type in Gnome Terminal: svn upd and hit Tab it's autocompleted to: svn update Is it possible to do something like that in my custom bash script?
1
vote
1answer
3k views

output terminal redirect to zenity

Let's explain you my doubt. We all know that >& is shell syntax for "fold a file descriptor into another". So 2>&1 means that i want to redirect stderr to the stdin, this is simple and ...
2
votes
1answer
928 views

Problem to write long lines in terminal

I have defined a PS1 prompt multi-line in my server with Ubuntu 11.04. The problem occurs when I write a long command, the line cuts before the end of terminal and it continues at beginning the same ...