Browsed by
Category: Linux

Text Processing in Linux

Text Processing in Linux

I originally created and posted this November 22, 2004. Here are some examples of using the utilities found on Unix (available on some other platforms also) for manipulating the text in files. awk and perl both allow writing full programs, but I primarily use both as short one-liner programs which allows them to be piped to/from other Unix programs. Each of these programs has capabilities that make it better than the others in some situations which I have attempted to…

Read More Read More

bash Shell Examples

bash Shell Examples

I originally created this on June 23, 2004. These examples primarily use the for loop in the bash shell. Count the number of lines with the_word in each .txt file for file in *.txt; do grep the_word $file | wc -l done This code creates directories (under the current directory, as written) for any groups whose names begin with dev-. for GRP in `getent group | cut -d: -f1 | grep ^dev-`; do mkdir $GRP done Create directories named dev1,…

Read More Read More

Unix find Examples

Unix find Examples

I originally created and posted these online on March 8, 2000. To recursively remove all files with a given name starting at the current directory, e.g., files called undo.Z, use find . -name undo.Z -exec rm {} \; To recursively move to the directory ~/public_html/cgi-bin/ all files belonging to user brezeald, use find . -user brezeald -exec mv {} ~/public_html/cgi-bin/ \; To recursively find all files with the name hosts starting at the current directory, use find . -name hosts…

Read More Read More

vi/vim notes

vi/vim notes

I first created and posted these notes online on May 28, 2002. They may be the most useful thing I ever do. I collected most of these over the years from several sources, but I can’t give proper credit since those links are all dead now. Changing Text cc change a line C change from current cursor position to the end-of-line cw change from current cursor position to the end of the word J joins the next line to the…

Read More Read More