Tip #189 Remove every file but one
It's easy to remove (or copy, move etc.) all files that match a given criteria, but harder to move all but ones excluded by a criteria.To do this we can combine grep's -v option with Unix command substitution:
Read more »
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 »
Tip #154 Port forwarding that automatically disconnects
If you want to tunnel a long-lived connection over SSH such that the tunnel goes away when the application disconnects, try something like the following example:Read more »
- TAGS:
Tip #224 Add header/footer to command output
If you want to surround the output of a command by a header or a footer try the following:Read more »
- TAGS:
- cat
Tip #141 Process files whose names may contain spaces
If the names of some of the files in a directory may contain spaces, combine find's "-print0" option with xargs' "-0" option:# this will behave incorrectly if some files or directories have spaces:
find . -type f | xargs ls -l
# this will work correctly:
find . -type f -print0 | xargs -0 ls -l Read more »
- TAGS:
Tip #172 Create daily backups
To create a set of backed up files with the current date added at the end of the file name try the following:Read more »
- TAGS:
- sed
Tip #209 Directory Tree
The following alias will print the directory structure from the current directory in tree format.Read more »
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
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