Questions tagged [bash]

Bash is the Bourne Again SHell, the successor to the classic Unix sh (shell).

Filter by
Sorted by
Tagged with
19 votes
2 answers
16k views

What does "--" (double dash) mean in this shell command?

I have this shell command: kill `cat -- $PIDFILE` What the double -- does here? Why not use just kill `cat $PIDFILE`
daniels's user avatar
  • 1,215
7 votes
6 answers
11k views

crontab environment

I have written various scripts to launch Java server applications, which are typically run for 24 hours before being shut down (by invoking the same script with a different parameter). The script ...
Adamski's user avatar
  • 281
3 votes
2 answers
2k views

How to change VGA mode after boot and login with ubuntu?

Is there a way to change the screen resolution of the console after the system has been booted? I've seen plenty on setting the vga= line in the boot and in the grub config but I'd like to be able to ...
Mech's user avatar
  • 660
2 votes
1 answer
3k views

Start a VPN session using a Terminal script

I use an OSX Terminal session to start a VPN connection. The command that I execute at the prompt is: /etc/netlock/cvc -c :: This works as expected. I would like to save this to a script file that ...
craibuc's user avatar
  • 467
1 vote
4 answers
2k views

How to do a text match in bash

I'm trying to find a nice way of checking some text in order to set a variable. For instance to perform the logic: 'if the version string is 1.x then set a flag'. One way of doing this is: ...
the_mandrill's user avatar
0 votes
3 answers
3k views

Convert all filenames to lowercase [duplicate]

Possible Duplicate: How can I recursively change the case of files and folders under bash How can I convert all file names to lowercase in a directory and its subdirectories, using a command or ...
user avatar
3 votes
1 answer
11k views

ApacheBench result to a file

I would like to save ApacheBench (ab) tool on linux to a file. When I run it with -v 2 it displays some results in my ssh window. How to move these data into a file and make sure that it will not ...
Tom Smykowski's user avatar
3 votes
1 answer
592 views

How can I record the running time of particular commands in Linux (specifically bash)?

I'm trying to collect some stats on how much time is spent 'waiting' for certain fairly short running tasks so I can justify purchase of some automated tools. I've written bash function wrappers ...
Mark McDonald's user avatar
1 vote
1 answer
409 views

Linux / Sendmail one liner having trouble with large directories

For whatever reason, spammers found a way to relay mail through a side-system. The exploit has already been addressed. The problem is that I had massive amount of emails in my /var/spool/mqueue ...
Mike B's user avatar
  • 12k
5 votes
2 answers
726 views

What does this Linux command do?

I have by a mistake written this command on a CentOS server xargs rpm -e|rpm -qa|grep test11 where I meant rpm -qa|grep test11|xargs rpm -e which should uninstall all packages matching "test11". ...
Sandra's user avatar
  • 10.5k
1 vote
2 answers
4k views

How to execute a bash shell script via a browser link

I have written a bash script that periodically checks a directory for newly added .ear files and copies them to the respective JBoss server's deploy directory.Before copying, it checks if JBoss is ...
user avatar
52 votes
3 answers
65k views

Find out which partition a directory is located on in Linux?

Is there a way to find out which partition a directory is located in? I know I can use df to list partitions and mount points but I need to be able to find out which partition any directory is ...
Camsoft's user avatar
  • 981
3 votes
3 answers
1k views

help with bash script using find and diff command

i have a bash script that i need help with: #!/bin/bash if [ -f "/suid.old" ] then find / -perm -4000 -o -perm -2000 ls > suid.old else find / -perm 4000 -o -perm -2000 ls > suid.new diff suid....
user avatar
2 votes
4 answers
3k views

cron script for scheduled backups

i am looking for a cron script which can do some backups. im mostly a web developer so am kind of newbish with bash/cron stuff. i want cron will copy all the files or directories in a "filelist.txt" ...
Will's user avatar
  • 441
2 votes
1 answer
756 views

Why is the displayed name in bash different from the one in /etc/passwd?

I remotely SSH login as root (using PUTTY), The bash shell prompt becomes: [root@yukiko /]# When I entered: getent passwd The first line I see is this one: root:x:0:0:root:/root:/bin/bash ...
bobo's user avatar
  • 619
6 votes
5 answers
9k views

user GPG key not able to be used by SUDO

I created a script that runs duplicity to backup files I have on a VPS,and uses a GPG key that I generated as a user. When I try and run this script as SUDO I get: GPGError: GPG Failed, see log ...
BassKozz's user avatar
  • 655
5 votes
2 answers
2k views

Freebsd doesn't show command output correctly in Putty

I have just installed the latest stable version of FreeBSD to a computer and I have the following problem: If, in Putty, I issue a command like ps uxa which gives long lines of output, they get ...
skrostislav's user avatar
0 votes
3 answers
995 views

Error when changing shell of root user in Solaris 10

I can't change my shell for root in Solaris 10. When i change, i can't login again after logout. The error is "no shell".
user avatar
4 votes
2 answers
930 views

Is it possible to get the real username inside of a script that was called using sudo?

I have a script that I call with sudo -- sudo script, and I want to be able to see the username of the user running the script (not root). Sticking whoami or id -un inside the script just gives me ...
Trey Piepmeier's user avatar
0 votes
1 answer
3k views

Restart apache process using shell script cannot find apache

I am trying to include a call to restart the apache2 server within an .sh script using PHP that runs daily to perform a maintenace routine on my server. I am able to kill the apache server and clear ...
coffeecoder's user avatar
28 votes
2 answers
23k views

Can I call pushd/popd and prevent it printing the stack?

After calling pushd/popd in bash, it will print off the current directory stack. Is there any way to prevent this behaviour, so that it will act 'quitely'? This sort of noise in a command is uncommon ...
Amandasaurus's user avatar
  • 32.3k
5 votes
1 answer
1k views

Should the 'nobody' user on my headless Ubuntu server have shell access?

I've read conflicting stuff on a few forums etc. regarding this. When I enter the following line: grep nobody /etc/passwd I get the following output nobody:x:65534:65534:nobody:/nonexistent:/bin/...
conorgriffin's user avatar
11 votes
2 answers
7k views

Linux - Find out the current working directory of a process?

If i have a process PID X, how can I find out what directory it was running in? I can see with ps aux | grep X the full command line that it was invoked with. However in this case it's ./script.sh, ...
Amandasaurus's user avatar
  • 32.3k
1 vote
3 answers
4k views

bash one-liner loop over directories throws errors

I'm trying to build a bash one-liner to loop over the directories within the current directory and tar the content into unique tars, using the directory name as the tar file name. I've got the basics ...
cori's user avatar
  • 381
3 votes
2 answers
994 views

how to change cron shell for OSX Leopard

I have a script that runs fine if I invoke it from the command line, using Bash. But when cron tries to run it, it fails with a "mysql: command not found" error. I think this is because cron is not ...
Jared Henderson's user avatar
102 votes
9 answers
185k views

mysqldump to a tar.gz

Usually after dumping a MySQL database with mysqldump command I immediately tar/gzip the resultant file. I'm looking for a way to do this in one command: So from this: mysqldump dbname -u root -p &...
pygorex1's user avatar
  • 1,201
4 votes
2 answers
1k views

Bash Scripting: Parse File Contents Into Array

Greetings, I'm writing a simple bash script that needs to parse the contents of a file into an array. Entries in the file are "newline" delimited -- so the file would look something like this: path/...
Skone's user avatar
  • 519
3 votes
3 answers
1k views

can you help me with this simple 'ulimit'?

I have a badly coded infinite looping program that I want to run on the command line - but not forever. I want to use ulimit so if it loops forever, it gets cut off. I'm trying: $> bash -c "...
rlb.usa's user avatar
  • 163
5 votes
2 answers
5k views

Using ulimit to limit the amount of memory a script can use

I have an ubuntu system and I have a script that runs regularly. I need to limit the maximum amount of memory that this script can use. AFAIK ulimit is the command to do this, however I can't get it ...
Amandasaurus's user avatar
  • 32.3k
24 votes
9 answers
60k views

Make ls print it all on one line (like in terminal)

ls prints differently depending on whether the output is to a terminal or to something else. e.g.: $ ls . file1 file2 $ ls . | head file1 file2 Is there some way to make ls print out on one line ...
Amandasaurus's user avatar
  • 32.3k
3 votes
4 answers
370 views

Good shell scripting guide [closed]

I have the Orielly's "Learning bash". I also refer to Advanced Bash-Scripting Guide(tldp.org/LDP/abs ). Any other good books on the subject ?
nitin's user avatar
  • 2,599
4 votes
3 answers
297 views

Creating thousands of files from shell

I have thousands of directories, all of them has this format; /var/www/vhosts/[USERNAME].company.com/conf/ and i have a file called x.txt, it's content should have [USERNAME] and some static text......
Devrim's user avatar
  • 1,187
54 votes
6 answers
40k views

Bash Loop - How to stop the loop when I press Control-C inside a command?

I am rsyncing a few directories. I have a bash terminal open and am executing something like this: for DIR in * ; do rsync -a $DIR example.com:somewhere/ ; done However if I want to stop the whole ...
Amandasaurus's user avatar
  • 32.3k
2 votes
1 answer
966 views

Cron Permission Denied

good day, I have a bash script in my home directory that works properly from the command line (file structure is default media temple DV. < noted for certain permission issues) but receive this ...
user avatar
4 votes
3 answers
8k views

How to apply CHMOD command to any file with a specific name recursively in Linux?

I need to know how to apply a CHMOD command to only files that have a specific name recursively? chmod 755 -R filename Something like above but it should apply to any filename that exists in any sub ...
Camsoft's user avatar
  • 981
0 votes
2 answers
163 views

How to autostart apps in OS X as a different user

I am playing with CouchDB and whenever I do, I first have to issue sudo couchdb -i -u couchdb couchdb -b This starts CouchDB as the user couchdb, group couchdb. I then also have to enter my ...
raoulsson's user avatar
  • 4,813
3 votes
1 answer
313 views

Avoid duplicates in bash history

Is there a way that I can remove repeated commands from bash history? For example: I run the mv command once, then I run the ls command n times. I have to press the up arrow n times to get the mv ...
user31985's user avatar
99 votes
9 answers
429k views

How can I fully log all bash scripts actions?

From my script output I want to capture ALL the logs data with error messages and redirect them all to log file. I have script like below: #!/bin/bash ( echo " `date` : part 1 - start " ssh -f ...
BlueMark's user avatar
  • 1,129
185 votes
14 answers
305k views

How to create a UUID in bash?

In Java it is possible to create a random UUID: UUID uuid = UUID.randomUUID(); How to do this in Bash?
raoulsson's user avatar
  • 4,813
9 votes
7 answers
39k views

Check to see if a directory exists remotely (shell script)

Is there a way to see if a directory exists on a remote server? Perhaps there's a better way, but I'm writing an application deployment script, and I want to create a directory on a remote server if ...
user avatar
6 votes
3 answers
12k views

How do I exclude a folder when performing file operations i.e. cp, mv, rm and chown etc. in Linux

How do you exclude a folder when performing file operations i.e. cp etc. I would currently use the wild card * to apply file operation to all, but I need to exclude one single folder. The command I'...
Camsoft's user avatar
  • 981
1 vote
1 answer
4k views

How to call a bash script from another script, as a different user? [duplicate]

Possible Duplicate: Run a shell script as a different user While writing scripts to automate the intialisation of SVN mirror repositories (svnsync), I again ran into problems trying to start ...
Jonik's user avatar
  • 3,021
13 votes
5 answers
35k views

Apply multiple .patch files

I have a directory with .patch files, generated using diff. I would like to apply all those patches using patch -p1 to another directory. But patch takes only one file, unless I cat. What would the ...
styts's user avatar
  • 255
2 votes
3 answers
152 views

How to deal with whitespaces in scripts

I would like to find certain files on my external disc and delete those. I created following script (to test I only use ls $i to check the output) for i in `find /media/My\ Book/ -name "OP_CACHE.IDX" ...
lostiniceland's user avatar
3 votes
3 answers
32k views

Deleting files from Remote FTP-Server older than x days

i've got a remote FTP server where i store some backups via cronjob. The Problem is that i only got a little amount of space so im doing incremental backups. I want to keep the backups about 14 days. ...
user25634's user avatar
0 votes
2 answers
4k views

Bash & blocking processes

Could you help me with the Bash syntax to achieve the following? Run a blocking process without blocking execution of the rest of the script. Run a standard "non-blocking" process (e.g. lsof). "...
xyz's user avatar
  • 501
5 votes
5 answers
19k views

Making a script into a linux service

-- EDIT, still some issues -- OK my script uses a loop to wait for network connections. So when I run it, even with daemon it will just sit there and not take me back to the shell. I tried su -c "/...
The Digital Ninja's user avatar
0 votes
1 answer
737 views

Rackspace Cloud API

I am creating bash script to store backup files on Rackspace (mosso). For now i am done with uploading and deleting files from containers. Next step is to remove files older than two weeks (remove ...
minnur's user avatar
  • 115
0 votes
2 answers
3k views

Ubuntu-Server bash colors not appearing on login

I am running Ubuntu Server 8.04 (hardy), and when I login remotely i can't see the colors when using ls, however after I type "bash" into the shell I see colors, I've already checked my .bashrc and ...
BassKozz's user avatar
  • 655
38 votes
4 answers
52k views

How to repeatedly call rsync until files are sucessfully transferred

I'm trying to syncronize files from a remote server that is not reliable, meaning the connection tends to fail "randomly" with rsync: connection unexpectedly closed Rsync is called with --...
Bruno Lopes's user avatar

1
65 66
67
68 69
72