file
commandwhich
commandcat
commandhead
commandtail
commandmore
and less
commandsfile
commandfile
tests each element passed as an argument to the command and
prints the file type back to the screen (standard output).
Examples:
|
||||
>> >> file /mnt/homes/tuckerm/photos/dsc00375.jpg dsc00375.jpg: JPEG image data, EXIF standard 0.73, 10752 x 2048 >> |
|
||||
>> >> file test.sxw test.sxw: Zip archive data, at least v2.0 to extract >> |
file
may use more than one argument:
|
||||
>> >> file money.pdf rails.mpeg money.pdf: PDF document, version 1.4 rails.mpeg: RIFF (little-endian) data, AVI >> |
|
||||
>> >> file *.mpg manualdrop1.mpg: RIFF (little-endian) data, AVI trials1.mpg: RIFF (little-endian) data, AVI >> |
which
command
which
returns the full (absolute) path of a shell command. The which
command
will search each directory included in your environment variable
$PATH
. Which
only returns the names of executatble
files found in the user's path. Files without the executable bit
will not be found.
Examples:
>>
>> which ssh
/usr/bin/ssh
>>
>> which ldd ls
/usr/bin/ldd
/usr/bin/ls
>>
>> which moo
>>
head
command
By default, head
returns the first ten lines of the file(s).
Different numbers of lines can be specified with the the
"-n" where "n" is substituted with a number:
head -99 somefile.txt
head -4 somefile.txt
head
can also take multiple arguments:
>>
>> head -3 junk.pl localback.sh
==> junk.pl <==
#!/usr/bin/perl
#
print "testing if conditionals\n";
==> localback.sh <==
#!/bin/bash
#
# Creates a daily backup to the local disk for general use.
head
can also use the wildcard:
>> head -1 t*.pl
==> test.pl <==
#!/usr/bin/perl
==> test3.pl <==
#!/usr/bin/perl
==> test4.pl <==
#!/usr/bin/perl
>>
>> head -2 test?.pl
==> test3.pl <==
#!/usr/bin/perl
#
==> test4.pl <==
#!/usr/bin/perl
#
>>
tail
command
By default, tail
returns the last ten lines of the file(s).
Like head
different numbers of lines can be specified
with the the
"-n" where "n" is substituted with a number:
tail -50 somefile.txt
tail -8 somefile.txt
tail
can also take multiple arguments:
tail
can also use the wildcard but you must use the "--lines -n" option:
>>
>> tail --lines -1 t*.pl
>>
>>
>> tail --lines -2 test?.pl
>>
cat
command
cat
displays the contents of a file to the terminal (standard
output). If multiple files or wildcards are given as arguments then
the outputs are streamed together to the terminal.
cat somefile.txt
cat *.txt
cat one.txt two.txt