Archive for the 'Linux' Category
In the first bash tutorial we went over brace expansions and a few history tricks. The goal of this post is to expand on that and teach more bash features.
Have you ever wondered when you typed a previous command in your history? This is easy to do with the $HISTTIMEFORMAT variable and bash >= 3.0. [...]
Overview
lsof or “List Open Files” is a favorite in my free software toolbox. It is so versatile there are few things you can’t do without it.
Here are some examples of real world lsof usage and a few things things you might not know it is capable of doing.
What process is holding onto /var/log/messages? lsof is [...]
Eric Butler did a very good writeup of this years Southern California Linux Expo. Instead of writing a rehash, you can read his post.
One particular thing to note is his mention of Sun’s true commitment towards Linux.
Unbeknownst to many, rpm supports random printf() style query strings via the –qf option. List all available tags with “rpm –querytags” and display them with “rpm -q –qf ‘%{QUERYVARIABLE}’. On some versions of rpm, you need to place multiple variables inside brackets ( [] ) to display them all properly.
Use the ARCH and NAME tags [...]
Brace expansions save you lots of typing:
$ ls
file1
$ cp file{1,2}
$ ls
file1 file2
$ mv file{1,1.old}; ls
file1.old file2
You can even use brace expansions in shell scripts:
#!/bin/bash
scp /path/to/{file1,dir2,file2} user@otherserver:/dump/
if [ $? -eq 0 ]; then
rm /path/to/{file1,dir2,file2}
fi
NOTE: In posix land, an exclamation mark is often referred to as a “bang”.
!! - aka “bang bang”. Runs the previous command [...]
Latest Entries
Archives
Categories
- Linux (5)
- Redhat (1)
- scripting (2)
- Systems Administration (2)
- Ubuntu (1)
- Uncategorized (1)