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
1answer
878 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
554 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
3k 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
614 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 ...
19
votes
4answers
29k 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
507 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
429 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
229 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
487 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
519 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
180 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
957 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
932 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; ...
5
votes
3answers
1k 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
965 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
522 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
536 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
634 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
689 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 ...
0
votes
4answers
11k views

Is there a difference between sudo su - root and sudo -u root -H /bin/bash?

Like title says, is there a difference between these two commands : sudo su - root sudo -u root -H /bin/bash I'm using GNU/Linux, if that makes a difference.
5
votes
2answers
4k views

Running piped bash script in background

I'm attempting to build a monitoring script to watch localhost communication using netcat. I have two scripts that I've built, one to start the monitoring loop and one for the loop itself. They are as ...
2
votes
1answer
287 views

Script to let the user cancel a shell logout

I want to write a script to display a message and possibly cancel a logout from an interactive shell. This is because I often run background jobs in some of my shells and in the spur of the moment I ...
4
votes
2answers
2k views

Can I create a man page for a script? [duplicate]

Possible Duplicate: How can I add man page entries for my own power tools? Most (if not all) Linux commands have their man pages that describe their usage options etc. Can I create similar ...
2
votes
2answers
310 views

Shell Prompt Customization? [closed]

I have used oh_my_zsh (and tinkered with bash_it) on multiple systems and have generally been happy with it, though I hate it's auto-correction feature and generally turn it off. My usual shell is ...
5
votes
1answer
577 views

What determines the path where the system searches for a file?

I am trying to get npm to work. In the process, I seem to have two versions of it installed: A corrupt one installed in ~/bin, and another I just compiled and ran make install to put it in ...
1
vote
1answer
923 views

How to make progress dialog for Bash in XFCE?

Previously, in KDE, this was simple -- I called KDialog with number of steps, I got DCOP handle in return, then I called dcop with that reference and step, and progress dialog got updated. However, ...
3
votes
3answers
3k views

How can I pass output of one command as an argument to another

A similar question has been asked, but since I am new to Unix the answer was not clear to me due to the context. What I want to do is to pass the output of one command as an argument to another. I am ...
4
votes
4answers
3k views

Command that highlights regex in text?

Is there a command that highlights a certain expression in text? I'm looking for something like the 'search' function in less, but with normal text output on stdout, instead of the less viewer. ...
5
votes
2answers
2k views

How to get top 5 most ram intensive applications from Bash?

So I look at avaliable to me servers load and see that some other user has created some really ram intensive app that kills my server hosting abileties. I wonder what is bash command to get top 5 ...
3
votes
1answer
741 views

Complete files from a different directory in bash [duplicate]

I wrote two functions push and pull to copy files to and from a directory ($FILE_EXCHANGE_DIR). I want bash to autocomplete names from that directory when I use the pull function. I want the ...
1
vote
1answer
427 views

How do I hide login information passed to command line programs from appearing in the process list?

I have to execute a program that passes in as command line options the username and password. Is there a way to hide the username & password from appearing in the /proc entry for this process.
1
vote
1answer
2k views

How to assign value of variable with regex (bash)?

I want to use regex in bash at line of variable assignment e.g. oldip="14\.130\.31\.172" oldip_a="14.130.31.172" << How to use regex to del all '\'? and assign to oldip_a Do you have any ...
3
votes
1answer
240 views

Alias in .bashrc doesn't seem to accept an argument [duplicate]

Possible Duplicate: In Bash, when to alias, when to script, and when to write a function? I'm trying to setup an alias in my .bashrc file, but it's not working as expected. I have this ...
1
vote
2answers
791 views

Is it possible to change the order of a glob?

I am trying to show all instances of a particular message from the syslog in chronological order by doing something like the following: grep squiggle /var/log/messages* Unfortunately the glob ...
3
votes
3answers
621 views

Configure bash globbing

After coming from cygwin, I'm quite confused about the bash (version 4.1.5) globbing on my Ubuntu 10.4. I'd love one of the following two possibilities: ignore . and .., match everything else ignore ...
1
vote
2answers
727 views

Bulk rename files with numbering

How do I bulk rename multiple files named Image401.jpg, Image402.jpg,... to Image 001.jpg, Image002.jpg, ... ?
2
votes
3answers
1k views

Kill backgrounded SSH when shell exits

I'm trying to spawn an SSH from my bash profile script that runs in the background for connection sharing (via its control socket). The problem I'm running into is a reliable way to ensure the SSH ...
5
votes
1answer
2k views

The best way to expand glob pattern?

I need to expand a glob pattern (like ../smth*/*, or /etc/cron*/) into a list of files, programmatically. What would be the best way to do it?
6
votes
3answers
15k views

How to write a bash script, that logs onto an other machine to do stuff?

Is it possible to write a bash script, that would be started from machine A, logs in on a different machine B by ssh (both machines A and B would be Linux-Machines), copys some files on to machine B ...
2
votes
1answer
227 views

Chown and the risk of corrupting the backup disk

I am about to modify the file ownership recursively in a filesystem that uses ACLs. Because it is my backup disk, I thought I'd solicit comments on the script before I run it. #!/bin/bash # Replace ...
6
votes
1answer
2k views

Bash read command and stdin redirection

As I understand the bash documentation both | and < redirect stdin. So, cmd | foo and foo < <(cmd) should be more or less equivalent. However, for the bash-internal read command this doesn't ...