env -i x=9 bash -c 'x=4;bash -c "echo x: /\$x/"' # then try w/o 'x=9' Bug or feature? Pls explain: /tmp $ env -i bash -c 'x=4;bash -c "echo x: /\$x/"' x: // /tmp $ env -i x=9 bash -c 'x=4;bash -c "echo x: /\$x/"' x: /4/ --snip ~ $ uname -r; echo $BASH_VERSION 2.6.27.41-170.2.117.fc10.i686 3.2.39(1)-release -- thx ... 20 May 2010 12:46
using bash pathname expansion for string matching Dear all, In bash, we can use 'case' statement so do some simple string matching. For example read quit case "$quit" in Y*|y*|"") exit 1 ;; *) ;; esac If we don't want to use case (since the condition is simple), we can use 'if' and 'grep' read quit if echo $quit | grep -vq '^[^Yy]'; then ex... 18 May 2010 01:39
Directory exclusion from the output of 'echo **' With globstar turned on, I can either list (in a recursive manner) every directory that follows the current working directory or, every directory and file that follows CWD. My question is: is there a glob pattern that eliminates directories from the listing before it is printed to stdout? The problem is that there ... 15 May 2010 19:10
Auto escaping ? Hello all, I would like some way to escape file names I get from something like that: (this is bash syntax) # Get the 10th file in the archive Image=$( zipinfo -1 "$1" | head -10 | tail -1 ) unzip -p "$1" "$Image" | pipe it somewhere The problem is that is $Image contains one of [ ] { } ( ) < > ' " \, etc Th... 21 May 2010 05:08
how to find and omit a directory containing a file entirely Hi, I want to use find to list my files, but exclude those in a directory containing a certain file. In the latest version of tar, there is --exclude-tag-all <http://www.gnu.org/software/tar/manual/html_section/exclude.html> to do this. I was wondering how to achieve the same effect using find. [quote] '--ex... 16 May 2010 21:12
replace strings based on a dictionary Dear all, I am looking for a good way to replace some strings in a file according to a dictionary saved in another file. Suppose the dictionary file has the following format func1 help func4 close .... The first column is the index and the second column is the value. The index strings should have no sp... 13 May 2010 21:34
Find and delete empty directories recursively In unix, how to do efficiently find and delete empty directories recursively If no regular files (or symlink) present, it is considered as empty. Directories with emtpy subdirectories are considered as empty also. TIA JL ... 14 May 2010 09:29
Coloring stdin, stdout, stderr differently Is it possible to make any of those a different color than the others? In any shell? ... 18 May 2010 17:00
Question about using ls Hi All I have below files, each backup have date code after it. moonhkt moonhkt.20100405 moonhkt.20100406 moonhkt.ksh moonhkt.ksh.20100406 moonhkt.p moonhkt.p.20100405 how to ls or other command display moonhkt and its backup file ? output as below moonhkt moonhkt.20100405 moonhkt.20100406 moo... 19 May 2010 21:35
How to pass OPTION? I use the following while loop to parse commandline options. while getopts 'a:b:h' OPTION do case $OPTION in a)ARCHIV="$OPTARG" ;; b)BACKUP="$OPTARG" ;; h)printf "Usage: %s [-a value] \n [-b value] \n" $(basename $0) >&2 exit 2 ... 13 May 2010 01:48 |