Tip #91 another solution to #67
For a fix of #67 that is a bit nicerfor support spaces in the arguments just fine, just make sure you quote "$i".
$ touch a
$ touch b\ c
$ for i in *; do ls "$i"; done;
Read more »
- TAGS:
- bash
Tip #94 Overwrite a file with zeroes
Overwrites a file with zeroes.Put in in your .bashrc or .bash_profile in Mac OS X.
Read more »
- TAGS:
- bash
Tip #95 Bash terminal size
Q: If I resize my xterm while another program is running, why doesn't bash notice the change?http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
Bash won't get SIGWINCH if another process is in the foreground.
Enable checkwinsize so that bash will check the terminal size when
it regains control.
Put this in your bash config somewhere (e.g. Gentoo has it in /etc/bash/bashrc):
Read more »
- TAGS:
- bash
Tip #96 Find occurrences of a string in a large code base without firing
A slight improvement to #64 -- drops one grep and adds line numbersRead more »
Tip #139
Selected Bash Keystrokes:Ctrl-U - Cuts everything to the left
Ctrl-W - Cuts the word to the left
Ctrl-Y - Pastes what's in the buffer
Ctrl-A - Go to beginning of line
Ctrl-E - Go to end of line Read more »
- TAGS:
- bash
Tip #140 Change extension on a group of files using only bash builtins an
To change the extension on a group of files using only bash builtins and mv:Read more »
- TAGS:
- bash
Tip #145 swap files
# Swap 2 files/dirs that are in the same dir# Usage: sw f1 f2
function sw {
f1=$1
f2=$2
if [ "x$f2" = "x" ]; then
echo "Usage: sw file1 file2"
echo " swap name of 2 files"
else
d1=$(dirname $f1)
d2=$(dirname $f2)
if [ "$d1" != "." -o "$d2" != "." ]; then
echo "sw: Can swap only files in current directory"
else
if [ -e "$f1" -a -e "$f2" ]; then
mv $f1 .sw.$f1
mv $f2 $f1
mv .sw.$f1 $f2
else
echo "sw: '$f1' and '$f2' must exist"
fi
fi
fi
} Read more »
- TAGS:
- bash
Tip #147 Find and Grep
Find all files with given name (you can use Bash expansion if you'd like), and Grep for a phrase:Read more »
alias aptitude at awk bash bc cal cat cd colrm comm cp csh curl cut date dd df dialog diff dirname dpkg du fc find fuser grep gs gzip history iconv kill ksh last less ln ls lsof lynx m4 md5sum mkdir mkfifo mkisofs mv mysql nc netstat openssl OSX perl ping popd ps pushd python read redirection rm scp screen sed sort ssh stat sudo svn tail tar tee test top tr uniq vim wc wget xargs