Top 16 Most Important File Command in linux | Linuxteach

Are you Linux user or looking for a chance to dive into it? Here I shared most widely used file command in Linux which wil help you to understand the basic file operation in linux.

There are 16 (seventeen) popular file related command in Linux such as file, cmp, comm, diff, which can be used to perform the various operation on the file

  1. file
  2. cmp
  3. comm
  4. diff
  5. ln
  6. split
  7. bc
  8. expr
  9. touch
  10. grep
  11. sort
  12. uniq
  13. factor
  14. find
  15. cut
  16. paste
file:File command examine its content and its file type.It has different argument and option to differentiate between other file.
syntax:file [option] filename;
option: -b(brief):- Do not prepend filename to output line
-C(compile):- write a magic.mgc output file
-e(checking printout):- Cause a checking printout of the magic file.
-F:(separator):- Use specified string separator between the filename and resulting file
cmp: cmp stands for compare which is used to compare the content of the two file and gives the standard output. if the is different in content then it gives the byte from where different content started.
syntax:cmp [option] file1 file2
comm: comm stands for common which is used to find the common content between two file.common content will be given to the standard output.
syntax:comm file1 file2
diff : diff stands for difference which gives the line which are different in both the file.
syntax: diff file1 file2
ln: ln command creates hard link between file.It link the target file with the link name.
syntax: ln file1 file2
split: split command split(divide) output into fixed size pieces of input.The default size for each split file os 1000 line.
syntax: split [option] [input]
option: -d:- use numeric suffix instead of alphabetic
-l:- Put number lines per output.
-n:- Generate chunks output file.
-aN:- use suffix of length N (default 2)
bc: bc command is used for calculation purpose.It has interactive mode,accepting input from the terminal and providing calculation on request.
syntax: type bc and press enter
option: -i:-forces interactive mode
-l:-Defines standard library
read() is a function which read the input from the standard input.
expr: expr command evaluates arguments as an expression. expr prints the output of expression.
syntax: expr (expression or argument)
example: expr( 2 + 4)

touch

Leave a comment