Questions about bash only, as opposed to other Bourne/POSIX shells. For all Bourne/POSIX-style shells, use the /shell tag instead.

learn more… | top users | synonyms

4
votes
3answers
786 views

What does the following Bash script mean/do?

What does the following script mean? exec 4<&0 0</etc/XX/cfg read line1 exec 0<&4 UPDATE Thanks for the answer, just one part I'm not sure: It redirects fd0 to fd4, and ...
2
votes
1answer
4k views

How can I delete a hidden folder?

I want to delete many configuration folder in my home user folder but I can't figure out how to delete them. How can I delete a hidden folder?
1
vote
1answer
1k views

Gnome Terminal won't autocomplete

My gnome-terminal on a ubuntu 10.10 machine is not working the way it should work. No autocomplete is working. ctrl + l won't clear the screen, bash prompt is simply a $ and nothing else. I got this ...
3
votes
1answer
757 views

Bash globbing hidden files

I'm trying the following globs in a bash shell: $ ls -d .* . .. .a .ab $ ls .a* .a .ab $ ls .[!.]* .a .ab $ ls .[!.]?* .ab Shouldn't the last expression mean "a dot followed by exactly one ...
1
vote
1answer
249 views

How can I get this java command to act on each file found by a find command?

I have this command inside a Bash shell script, the intention of which is to apply a java command, htmlcompressor, to each HTML file found in a directory: find $DIR -type f -name '*.html' -exec java ...
0
votes
2answers
737 views

Errors when loading terminal

Every time I run a new terminal window (before I do a single thing), I am greeted with these messages: env: bash: No such file or directory env: bash: No such file or directory env: bash: No such ...
5
votes
3answers
2k views

Remove many many many files from a folder

I have a folder with 137795 files in it. I need to delete all of them. When I run rm * I get -bash: /bin/rm: Argument list too long. How do I get past this error?
0
votes
1answer
236 views

Moving Data From Old System to New System via NFS Mount

My old system was running RHEL 5,(systemold.blah.blah), and I wanted to update the server with as little downtime as possible, so I built out a new system (systemnew.blah.blah) and put RHEL 6 on it. ...
2
votes
1answer
148 views

Problem with find and variables

I have tried different variations of the following but nothing seems to work Basically when find gets executed nothing appears to happen. Below I present my bash function code and my output when I run ...
2
votes
1answer
2k views

Variable substitution into a sed script

After running this code #!/bin/bash rm -f myfile myfile-individual echo "Greetings, foobar!" > myfile MYSTRING="Jack" cat myfile | sed 's:foobar:$MYSTRING:' > myfile-individual we end up with ...
7
votes
8answers
3k views

Bash, remove oldest files

I`m trying to delete old files from directory and leave only 3 newest files. cd /home/user1/test while [ `ls -lAR | grep ^- | wc -l` < 3 ] ; do rm `ls -t1 /home/user/test | tail -1` ...
27
votes
4answers
2k views

Quick way to include a directory path when calling mv? [duplicate]

Often I will work out of the root of a rails directory where I find my self navigating the same path twice every time I would like to move a file: mv app/views/layouts/application.html.erb ...
3
votes
2answers
3k views

How to change the prompt in Linux?

The default prompt will be root@monu dev]# Can we change the "root@monu" part and give it a desired name?
0
votes
1answer
2k views

How to pkill from a script?

How can I write a script that basically just runs pkill -HUP inetd? I want to restart inetd via a script so I can schedule it to run at a particular time. I tried to write it myself, but I'm getting a ...
8
votes
4answers
790 views

What is the easiest way to execute text from tail at the command line?

Sometimes I'm working on a new (ubuntu) box and I type git and am alerted: The program 'git' is currently not installed. You can install it by typing: apt-get install git-core If that happens I ...
2
votes
1answer
492 views

Is it possible to customise the prompt to show the if there are any background jobs?

Is it possible to customise the bash prompt to show the if there are any background jobs? I find it easy to forget that there are background jobs. Say if the prompt was... $ Is there a way to ...
0
votes
1answer
851 views

Using Awk To Parse Individual Lines

Here is the output from qacct -o Total : OWNER WALLCLOCK UTIME STIME CPU MEMORY IO IOW ...
2
votes
3answers
3k views

How to insert tab character in “dialog”?

I'm using the linux "dialog" utility to create a simple UI. However, there is a text in infobox and I want to insert tab characters in order to properly align the text. But it seems, that dialog ...
3
votes
1answer
369 views

Why are these aliases failing?

I am attempting to put some alias definitions in .bashrc. Like this: #Convienience aliases alias ll='ls -l' alias ldir='ls -p | grep "/"' #Temporary aliases alias mvFooLog='mv ~/Projects/Foo/Log.txt ...
1
vote
1answer
493 views

What is the difference between $var and “$var”? [duplicate]

Possible Duplicate: $VAR vs ${VAR} and to quote or not to quote I assigned a variable var a value as follows: pradeep@pradeep-laptop:~$ var="Pradeep > is > a good > boy" ...
0
votes
2answers
2k views

How to direct bash network request through a socket5 proxy?

I know how to use http_proxy to redirect http request, but how to redirect the data with a socket5 proxy such as a SSH tunnel?
2
votes
2answers
844 views

Cannot enter a forward slash character when logging in via ssh

When I ssh into one of our servers, I cannot enter a forward slash character, which makes it difficult to do pretty much anything (like ls /). How can I get the forward slash to work? Some ...
4
votes
1answer
899 views

How to check if an application is running with a bash script

I have the gnome-run application in my home folder. I have now added the application to run when I press Meta+R (i added it in in ccsm). The problem is that if I have the gnome-run program open and I ...
1
vote
2answers
570 views

Script that uses MySQL query to automatically remove output

I have this query that outputs updates older than 7 days from a database. How would I make a script that takes the MySQL statement and puts it into a script to be executed by cron. echo "select name, ...
2
votes
2answers
4k views

curl several files and save output in one file

I am using curl to grab the HTML of a website. I want to only grab the first 20 lines, and save this in an external file. I need to grab about 10 URLs, and want to save all of them in the same file. ...
4
votes
1answer
633 views

Home key acting strange in bash (tty and X) on long input strings

When I hit Home if my current input is short enough (say, <36 characters), it works fine. However, when I've typed a longer command and then want to go back to the beginning, it seems like it does ...
22
votes
4answers
32k views

How to cut by tab character

I want to use cut command to break input into fields and get the second field. cut -f2 -d' ' <--- How can I tell it to use tab instead of space
3
votes
2answers
2k views

How can I force a bash loop to end if it runs x times in x seconds?

I'm trying to grab batches of input from a remote pipe via ssh. My script below works ok, but I would like to add some sort of check into it so that if something were to go wrong or break the loop ...
1
vote
3answers
1k views

Combining Awk with Curl

How would I set my curl statement so that it puts the value of each $3 in for the username, and the value of each $4 for the wallclock information? Some further information I am trying to take the ...
4
votes
1answer
2k views

Replace variable read from a text file (so they can be interpreted)

I tried several stuff with not luck so maybe one of you experts can help me (I hope!). I want to store in a text file some select statement that contain variables like a date: $ cat res.txt select ...
1
vote
1answer
521 views

Script using CURL to add information to site every month

I am very new at bash, so forgive me for the novice question. Here is my curl call: curl -d 'username=cdaniels&wallclock=391324502' 'https://www-dev.***.***.edu/clusterusage/rest/update.html'; ...
2
votes
1answer
456 views

readline: unix-word-rubout, but backwards, is it possible?

I'm trying to set up my .inputrc to perform a backwards unix-word-rubout but I'm currently failing at doing so. I have M-w mapped in my .inputrc. this does not work: "\eu": universal-argument "\ew": ...
2
votes
1answer
152 views

using logrorate with a complex logging directory

An application has a log directory, in which a alot of log output is created. The file structure in this log directory looks something like this: localhost:/var/log/myapp # ls appClient22334.a ...
4
votes
2answers
236 views

Why 2 linux machine behave differently with command of the same syntax?

I am using 2 machine , which is both Red Hat Enterprise Linux AS release 3 (Taroon Update 2) ( I check it in /etc/*-release ). I checked they are using the same default shell by ps -p $$, which is ...
1
vote
3answers
501 views

Accessing bash [internal] brace expansion iteration number/variable

Question: Is it possible to access which number of a bash iteration is currently being processed? Psuedo-Command mv {1..5}.something.{1..5} $x1.$x2.something Note: This is a logical ...
2
votes
1answer
523 views

root can only login with bash restricted mode

I was implementing a series of recommendations to 'harden' my linux server, involving lots and lots of changes. Linux is CentOS 6.2, kernel 2.6.32-220.*. I'm currently using tty2..tty5 (no X/GUI etc) ...
7
votes
3answers
3k views

Reading passwords without showing on screen in Bash Scripts

How to read passwords in bash scripts in a way like tools which are not showing it on terminal ? (Changing font to black on black might be tricky by easy to copy&paste - so it's not solution)
4
votes
1answer
183 views

How can I act on the results of the “locate” command?

I'm trying to find where check_dns is defined in nagios' commands.cfg file, although there are quite a few files. I know I could run something like find / -name "command.cfg" -exec grep check_dns {} ...
3
votes
2answers
968 views

simple script rotating table

I'm trying to write a simple script, that just rotates csv table. I mean I have some file: head1;head2;head3 field11;field12;field13 and so on. All I want, just to make my file ...
-1
votes
2answers
1k views

Why can't I create a directory by full relative path argument?

Why can't I create a directory by full relative path argument? Here is what I try: #!/bin/bash args=("$@") # Print the command and run it. Exit the script on failure. run() { if $VERBOSE; ...
6
votes
3answers
2k views

Run a vim macro from inside a bash script

In a bash script I want to edit a file. Is there a way to write a macro in vim, save it and then call it in bash script?
0
votes
2answers
113 views

Way to determine where certain global parameter is configured [duplicate]

Possible Duplicate: How to determine where an environment variable came from I wonder if there is a way to determine the location of the file where certain configuration exists. For example ...
0
votes
2answers
5k views

Trying to set JAVA_HOME in ~/.bashrc

I have added this line at the end of ~/.bashrc export JAVA_HOME=/usr/java/jdk1.5.0_07/bin/java But when I execute echo $JAVA_HOME, I don't get anything as output, I expected ...
2
votes
0answers
108 views

How does << work and what is it called? [duplicate]

Possible Duplicate: Correct textual name for << I am learning about Go and saw this usage I've never seen before (from http://golang.org/doc/install.html): $ cat >hello.go ...
5
votes
1answer
977 views

playing a sound/notification in finch over ssh on my local machine

So I have finch, a command line chat client (think pidgin) running on a remote machine that I ssh into. finch has notification sounds and can run a command when certain events occur, letting you pass ...
1
vote
1answer
2k views

Run expect inside a bash script as another user

I am writing a bash script to install some small software I'm developing. That script is run with sudo (as root), but some of the commands that are executed by the script need (or should be) run with ...
4
votes
2answers
538 views

is it possible to send the remote connector ip via netcat?

Actually I want to make something like ifconfig.me functionality but only for my internal network. I see it the way smth on server listens some port and send ip of connected remote machine. Seems nc ...
2
votes
5answers
566 views

Is it possible to reference the most recently modified file in a command line argument?

I frequently download PDF files with heinous numeric file names from my browser. These automatically go into ~/Downloads. Ideally I would like to just be able to open these files with: evince "the ...
8
votes
3answers
658 views

Escape sequences in output of script called from ncurses application

I'm currently running mcabber as my Jabber client (which uses ncurses) in a tmux session on my homeserver. Locally i run iTerm2 as a terminal emulator, which supports the triggering of growl ...
11
votes
2answers
708 views

What is the difference between : and true?

In bash: $ type : : is a shell builtin $ type true true is a shell builtin Looks like they are the same, but they don't give the same system trace: $ strace : strace: :: command not found $ strace ...