Skip to main content

Posts

Showing posts from January, 2022

head command in unix

    Head Command Examples The head command in unix or linux system is used to print the first N lines from the file to the terminal. The syntax of head command is  head [options] [files] The  head command options  are:  ·                        c : Prints the first N bytes of file; With leading -, prints all but the last N bytes of the file. ·                        n : Prints first N lines; With leading - print all but the last N lines of each file. Head Command Examples :  Create the following file in your linux or unix operating system for practicing the examples:  > cat example.txt linux storage ubuntu os fedora 1. Display first 10 lines  By default, the head command prints the first 10 lines from a file.  > head example.txt 2. Display first N lines  Use the -n option to  print the first n lines from a file . The following example prints the first 2 lines from the file:  > head -n2 example.txt linux storage u

find command in unix

  Find Command in Unix and Linux Examples Find is one of the powerful utility of Unix (or Linux) used for searching the files in a directory hierarchy. The syntax of find command is find [pathnames] [conditions] Let see some practical exercises on using find command. 1.  How to run the last executed find command? !find This will execute the last find command. It also displays the last find command executed along with the result on the terminal. 2.  How to find for a file using name? find -name "sum.java" ./bkp/sum.java ./sum.java This will find all the files with name "sum.java" in the current directory and sub-directories. 3.  How to find for files using name and ignoring case? find -iname "sum.java" ./SUM.java ./bkp/sum.java ./sum.java This will find all the files with name "sum.java" while ignoring the case in the current directory and sub-directories. 4.  How to find for a fi