bash

PHP cli Memory usage optimization

Hello I am trying to code a custom url_rewriter for squid. & also with using some other url_rewriter programs like squidGuard so have to use a wrapper to able use both or any other program. when i try to loop with php. (that's the way how squid communicates with external programs. STDIN/STDOUT. it gives you a url & you have to sen...

Setting up Mercurial for members of a unix group

I have a Mercurial repository set up on a Linux server, and some (but not all) users have permission to push to it. They connect to the repository over ssh. These users are members of a unix group together. Below is the script I'm using to alter a repository to allow it to receive pushes from them. Can this be improved? Are there unnec...

What happens when I execute a unix shell script using a '.' command?

For e.g., when I say ". .bashrc" on my linux command prompt, is there a corresponding binary/script that gets executed in place of the first dot? If the dot itself is a command, where is its location? ...

recursively add file extension to all files

I have a few directories and sub-directories containing files with no file extension. I want to add .jpg to all the files contained within these directories. I've seen bash scripts for changing the file extension but not for just adding one. It also needs to be recursive, can someone help please? ...

terminal color in ruby?

hi is there a ruby modul for colorize strings in a linux terminal? ...

Including String Expressions in bash Commands

How do I include a string with an expression in a command in a bash script? Consider the following: #!/bin/bash exclusions='Database|information_schema|mysql' echo "mysql -e 'SHOW DATABASES' | grep -E -v '$exclusions' > outfile" mysql -e 'SHOW DATABASES' | grep -E -v '$exclusions' > outfile The script prints to the screen: mysql -e...

Emacs ido-style shell

Is there a command line shell or shell customization that supports emacs-style ido find file? In emacs, I can navigate to a directory extremely quickly using C-x C-f and (ido-mode t). Ideally, I'm looking for a solution that can be used outside of emacs. Though I'd be open for a way to quickly change directories within an eshell buffe...

Shortest way to swap two files in bash

Can two files be swapped in bash? Or, can they be swapped in a shorter way than this: cp old tmp cp curr old cp tmp curr rm tmp ...

Capturing output of find . -print0 into a bash array

Using find . -print0 seems to be the only safe way of obtaining a list of files in bash due to the possibility of filenames containing spaces, newlines, quotation marks etc. However, I'm having a hard time actually making find's output useful within bash or with other command line utilities. The only way I have managed to make use of th...

Padding zeros in a string

I'm writing a bash script to get some podcasts. The problem is that some of the podcast numbers are one digits while others are two/three digits, therefore I need to pad them to make them all 3 digits. I tried the following: n=1 n = printf %03d $n wget http://aolradio.podcast.aol.com/sn/SN-$n.mp3 but the variable 'n' doesn't stay ...

Shell scripting. Command substitution issue in my script.

Hi mates, On both, my Cygwin and my Linux box (Debian) I'm experiencing same issue: I'm working in a shell script with some kind of formatting ids, I want to add a backslash () before a slash occurrence (/). My sed script is working well at my terminal: # export someid="314-12345/08" # echo "${someid}" | sed 's/\//\\\//' Output: 3...

BASH add in line

hi i want write code to add in line for ex open inittab file and add c2:1235:respawn:/sbin/agetty 38400 tty2 linux c3:1235:respawn:/sbin/agetty 38400 tty3 linux c4:1235:respawn:/sbin/agetty 38400 tty4 linux c5:1235:respawn:/sbin/agetty 38400 tty5 linux c6:12345:respawn:/sbin/agetty 38400 tty6 linux <<~~~ i want add code here # Local...

Split Files using tar ,gz,zip or bzip2

Hello, i need to compress file and it's giganitc file :D the size is about 17-20 GB i need to split it to files in size around 1GB for each part , i tried to googleit and found way using split,cat command and it did not work at all in large files , also it wont work in Windows i need to extarct it on windows machine, thanks in advance ...

BASH Variables with multiple commands and reentrant

I have a bash script that sources contents from another file. The contents of the other file are commands I would like to execute and compare the return value. Some of the commands are have multiple commands separated by either a semicolon (;) or by ampersands (&&) and I can't seem to make this work. To work on this, I created some te...

Setting bash command-line variable to start my application

I'm pretty new to programming for Linux environments, so I don't exactly know what to search for in order to answer this question for myself. I need to understand how applications set the shell to accept a certain command to start them. For example, you can start Firefox from the command line by executing the command: firefox. I don't k...

rsync remote site with bash

Hello All Hope you can advise I want to use rsync to carry out my FTP transactions but with bash. How can I add the password to the rsync command. I have for example. rsync -r -update [email protected]:/public_html/ /var/www/domin.com/public_html Hope you can advise. Thank you in advance. ...

bash/cygwin/$PATH: Do I really have to reboot to alter $PATH?

I wanted to use the Python installed under cygwin rather than one installed under WinXP directly, so I edited ~/.bashrc and sourced it. Nothing changed. I tried other things, but nothing I did changed $PATH in any way. So I rebooted. Aha; now $PATH has changed to what I wanted. But, can anyone explain WHY this happened? When do cha...

How to compare 2 symbolic links in unix (Linux)?

What would be an elegant way of comparing 2 symbolic links in Unix? Assume I have entered the following commands: ln -s /usr/share/g s1 ln -s /usr/share/g s2 ln -s ../share/g /usr/lib/s3 ln -s /usr/share/h s4 then I would like to have a command that says that s1 and s2 are equal (whether /usr/share/g actually exists is not relevant),...

Bash case syntax - meaning of "-@"

I'm not familiar with the semantics of the "-@" in the bash script snippet below, which is from /etc/bash_completion.d/subversion. I'm trying to understand why bash reports "syntax error near unexpected token '(' on this line, I have two questions: What is "-@()" expected to do here? Why might bash be unhappy with this statement? case...

How to issue "module load" in a shell or Perl script (i.e., non-interactively)

I can use the "module load xyz" command interactively, but when run from a script, it says it can't find the "module" command. Is there any way of loading modules in a script? ...