Shell
Shell programming or scripting related.
Listing absolute file paths in a directory
Submitted by gotdon on Thu, 08/06/2009 - 11:37
I recently ran into a situation where I needed to list a the absolute path to a file. I was not able to use find or grep. I found useful command below and believe it should be added to any Unix sysadmins toolbox. Here is the command.
This is a for loop loops through each line in `ls -1` (This lists one file per line). It then prints out the current working directory (PWD) followed by the variable i which contains each item in the list.
for i in `ls -1`; do echo $PWD/$i; done
Here is a short description of what it does:This is a for loop loops through each line in `ls -1` (This lists one file per line). It then prints out the current working directory (PWD) followed by the variable i which contains each item in the list.
Shell - Saving keystrokes by using !$
Submitted by tuxtutorials on Sun, 03/01/2009 - 20:19This is a quick tip on using your shell more efficiently by using !$. How !$ works is it takes the last argument you supplied in your last command and allows you to repeat it.
Here is a good example of how to use it:
cp source.tar.gz /usr/local/src
Here I am just copying a source.tar.gz file into /usr/local/src so I can begin to compile. To save me time of typing out
cd /usr/local/src
I can simply issue:
cd !$

