Interesting Unix Material
Unix Interesting Materials
Every word of a file can be placed on a separate line by typing:
cat old_filename | tr -cs A-Za-z '\012' > new_filename
The following lists all words in filename in alphabetical order:
cat filename | tr -cs A-Za-z '\012' | tr A-Z a-z | sort | uniq
You can find out when the file .rhosts was last modified by typing:
echo .rhosts last modified on `/bin/ls -l .rhosts | cut -c33-44`
Typing head -n displays the first n lines of a file. And typing last lists the last logins.
grep '^...............$' /usr/share/dict/words | grep -v '\(.\).*\1'
returns all the words in /usr/share/dict/words that are fifteen letters long and do not contain the same letter twice.
grep 'a[^aeiou]*e[^aeiou]*i[^aeiou]*o[^aeiou]*u' /usr/share/dict/words
returns all the words in /usr/share/dict/words that contain all of the vowels in the correct order.
Site Statistics:
Unix ---> Removing files with strange names: There may come a time that you will discover that you have somehow created a file with a strange name that cannot be removed through conventional means. This section contains some unconventional approaches that may aid in removing such files.
Files that begin with a dash can be removed by typing:
rm ./-filename
A couple other ways that may work are
rm -- -filename
and rm - -filename
Now let's suppose that we an even nastier filename. One that I ran across this summer was a file with no filename. The solution I used to remove it was to type:
rm -i *
This executes the rm command in interactive mode. I then answered "yes" to the query to remove the nameless file and "no" to all the other queries about the rest of the files.
Another method I could have used would be to obtain the inode number of the nameless file with:
ls -i
and then type:
find . -inum number -ok rm '{}' \;
where number is the inode number.
The -ok flag causes a confirmation prompt to be displayed. If you would rather live on the edge and not be bothered with the prompting, you can use -exec in place of -ok.
Suppose you didn't want to remove the file with the funny name, but wanted to rename it so that you could access it more readily. This can be accomplished by following the previous procedure with the following modification to the find command:
find . -inum number -ok mv '{}' new_filename \;
Checking peoples online status: Fingering people
When fingering someone on the same machine as you, then typing:
finger -ml (username)
will be a lot faster than just
finger (username)
Checking when they last logged on:
To find when people last used the current machine you are using, then type in the command:
last (username)
Depending on how much the computer is used will determine how long the resulting list will be.
This is still very much under construction.
cat old_filename | tr -cs A-Za-z '\012' > new_filename
The following lists all words in filename in alphabetical order:
cat filename | tr -cs A-Za-z '\012' | tr A-Z a-z | sort | uniq
You can find out when the file .rhosts was last modified by typing:
echo .rhosts last modified on `/bin/ls -l .rhosts | cut -c33-44`
Typing head -n displays the first n lines of a file. And typing last lists the last logins.
grep '^...............$' /usr/share/dict/words | grep -v '\(.\).*\1'
returns all the words in /usr/share/dict/words that are fifteen letters long and do not contain the same letter twice.
grep 'a[^aeiou]*e[^aeiou]*i[^aeiou]*o[^aeiou]*u' /usr/share/dict/words
returns all the words in /usr/share/dict/words that contain all of the vowels in the correct order.
Site Statistics:
Unix ---> Removing files with strange names: There may come a time that you will discover that you have somehow created a file with a strange name that cannot be removed through conventional means. This section contains some unconventional approaches that may aid in removing such files.
Files that begin with a dash can be removed by typing:
rm ./-filename
A couple other ways that may work are
rm -- -filename
and rm - -filename
Now let's suppose that we an even nastier filename. One that I ran across this summer was a file with no filename. The solution I used to remove it was to type:
rm -i *
This executes the rm command in interactive mode. I then answered "yes" to the query to remove the nameless file and "no" to all the other queries about the rest of the files.
Another method I could have used would be to obtain the inode number of the nameless file with:
ls -i
and then type:
find . -inum number -ok rm '{}' \;
where number is the inode number.
The -ok flag causes a confirmation prompt to be displayed. If you would rather live on the edge and not be bothered with the prompting, you can use -exec in place of -ok.
Suppose you didn't want to remove the file with the funny name, but wanted to rename it so that you could access it more readily. This can be accomplished by following the previous procedure with the following modification to the find command:
find . -inum number -ok mv '{}' new_filename \;
Checking peoples online status: Fingering people
When fingering someone on the same machine as you, then typing:
finger -ml (username)
will be a lot faster than just
finger (username)
Checking when they last logged on:
To find when people last used the current machine you are using, then type in the command:
last (username)
Depending on how much the computer is used will determine how long the resulting list will be.
This is still very much under construction.