Commands Associated with Files
Return to Main Menu
| File Organization Menu
| DOWN
lpr filename(s)
prints filename(s) on the default printer; the default printer is usually a line print which excepts only text, so please send only text files
Example:
lpr list.txt
Return to Main Menu
| File Organization Menu
| Associated Command Menu
| UP
| DOWN
rm [-i,-r] filename(s)
remove (delete) the specified file(s). With -i, the user is prompted before each file is deleted. With -r, if a directory is specified, the directory and all files in it are deleted.
Example:
rm list.*
rm -r ~/temp
Return to Main Menu
| File Organization Menu
| Associated Command Menu
| UP
| DOWN
mv [-i,-r] <filename(s)> or <directoryname(s)>
moves the specified files to the specified directory. Files created in the new directory have the same name as the original files. Existing files with the same name are overwritten. With -i, the user is prompted before each file is moved. The -r is used when moving directories. It means to recursively the directory and all of its nested subdirectories.
mv [-i] file1 file2
same as above, but moves a single file to a new filename. Complete or relative pathnames may be used.
Example:
mv list.* ~/temp
mv -i lis?.txt ~/temp
Return to Main Menu
| File Organization Menu
| Associated Command Menu
| UP
| DOWN
cp [-i,-r] <filename(s)> or <directoryname(s)>
copies the specified files to the specified directory. Files created in the new directory have the same name as the original files. Existing files with the same name are overwritten. With -i, the user is prompted before each file is copied. The -r is used when copying directories. It means to recursively copy or move the directory and all of its nested subdirectories.
cp [-i] file1 file2
ame as above, but copies a single file to a new filename. Complete or relative pathnames may be used.
Example:
cp letter.doc Mail/Jean/jan.10
cp letter.txt newletter
Return to Main Menu
| File Organization Menu
| Associated Command Menu
| UP
| DOWN
- grep string <filename> - prints to standard output all lines containing string in file <filename>
- grep is a filter, i.e. it accepts input from standard input and writes to standard output
- The string used in grep may use a special group of wild card characters known as regular expressions:
- <period>
- any character (not ?)
- *
- a group of characters
- [abc]
- either a, b, or c
- grep is used very frequently in pipes and shell scripts as a means of filtering data.
Example:
grep <any pattern> <file>
Return to Main Menu
| File Organization Menu
| Associated Command Menu
| UP
| DOWN
- > - Send the output
- < - Get the input
- >> - Append output to
- | - Use the output of the command to the left as the input to the
command to the right
Click here for Examples
Return to Main Menu
| File Organization Menu
| Associated Command Menu
| UP
Examples:
ls > filelist
Result:
The listing of the current directory is placed in a file called filelist
ls >> filelist
Result:
The listing of the current directory is Appended to the file called filelist
Mail fred < hello
Result:
Mails a file called hello to the user fred
ls -la | more
Result:
The listing of the current directory including dot files in long format one page at a time
cat letter1 letter2 > letter3
Result:
Concatenates the two files called letter1 and letter2 and place the output into a file called letter3
Return to Main Menu
| File Organization Menu
| Redirection Selection