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

learn more… | top users | synonyms (1)

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
76 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 ...
27
votes
2answers
102k views

How to use variables in 'sed' command?

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?
9
votes
3answers
16k 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
287 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
680 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
17k 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
633 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
848 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
127 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
8k 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
232 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
16k 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
419 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 ...
4
votes
1answer
628 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
16k 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
825 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 ...
19
votes
8answers
51k 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
5k 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
10k 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
804 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
7k 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
353 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
713 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
3k 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
122 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
3k 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
424 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
968 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 ...
33
votes
9answers
27k 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
674 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?
29
votes
4answers
11k 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
960 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 ...
32
votes
2answers
8k views

Is it possible to make writing to .bash_history immediate?

I often open lots and lots of Terminals [Right now I have 7 open on this workspace] and I often search history with grep to find a command I've just written recently, but I don't want to hunt down the ...
0
votes
0answers
72 views

How do I make nautilus reload emblems when changed by a script? [duplicate]

Possible Duplicate: Is there any tweak to bring back emblems in Nautilus? I am writing a script to manage my downloads folder. It will automatically delete items older than a month (or any ...
0
votes
1answer
1k views

bash script and zenity progress

I have this cmds: (youtube-dl http://www.youtube.com/watch?v=HhoewflkQu0) | zenity --progress --width=400 --height=100 --title="Scaricamento" --text "Scaricamento in corso..." --auto-close --pulsate ...
3
votes
2answers
2k views

Where to put custom .bashrc stuff, in .bash_local?

Just upgraded to 11.10, and prompted me to wondering where is now the preferred way to put customised .bashrc bits? I have some aliases, some env variables, and a python virtualenvwrapper script, for ...
5
votes
2answers
1k views

How to set env with a dot?

I tried doing that with export and set env, but it did not work. how to do it? for example ~/directory$ export a.home=1 bash: export: `a.home=1': not a valid identifier
1
vote
2answers
286 views

Opening program from nautilus through custom script

Would like to open all avi and mpeg files from folders in nautilus into a script that opens the file and moves the window using wmctrl. Basically, I need to open all media files with a script that ...
15
votes
4answers
2k views

How (and where) can one change 'user@host $:' pattern in gnome-terminal?

When I start terminal in Ubuntu, I see: ilya@HOST:~$ I need to add a timestamp to this, something like: 2011-10-09T09:32:00 ilya@HOST:~$ How can I configure this?
2
votes
2answers
720 views

Recover files without an extension after deleting them with a BASH command

Last night, I used exiftool to batch rename a collection of .mov files. Some of the files were renamed as required, but many of them were left without an extension. I think the required EXIF tag that ...
12
votes
3answers
2k views

How to efficiently send text entered on the command line to the system clipboard without using the mouse?

Say I've typed the following long command into the command line $ some very long command that I want to copy to the clipboard How can I get this onto the system clipboard efficiently? I'm using ...
1
vote
2answers
263 views

Need to make a shortcut command using xargs

I always want to kill a process id which listening on Port 3000. So presently I am using, 1.lsof -i tcp:3000 will give output as, COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME ruby ...
2
votes
1answer
3k views

When I type in terminal: export JDK_HOME=“/usr/lib/jvm/java-6-sun/”, where does it get stored?

I have tried multiple locations, but with no luck of finding where was it added: .bashrc .bash_profile /etc/profile /etc/environment .profile When I do echo $JDK_HOME, I get what I expect ...
6
votes
2answers
9k views

“command not found” when running “lessc” from bash

I have installed lessc via npm, Node.js Package Manager, and when I run lessc from terminal using lessc /var/www/less/style.less /var/www/css/style.css it works perfectly. However, when I put this ...
1
vote
2answers
216 views

Automatically run a command upon entering a certain directory?

I'm using virtualenv with django and so I have say two different directories say: ~/Development/site1 ~/Development/site2 So to set up my enviroment I normally go to ~/Development/site1 then run ...
2
votes
2answers
881 views

enable auto-completion of apt-get for non-privileged user?

I've enabled apt-get in SUDO without password , and bash autocompletion for it need to be enabled as well , but how ? If i try to source that file: %> . /etc/bash_completion.d/apt No command ...