Linux – wc

Linux wc command The Linux wc command is used to count the number of lines, words, and byte (character) in a file or input stream. Syntax: wc [OPITON] [FILE} Example: Use -l to count the number of lines in a file wc -l myfile.txt Use -w to count the number of words in a file wc -w myfile.txt Use -c to count the number of bytes in a file. You can use this to count character in a file wc -c myfile.txt Use wc with Piped Input You can also…

Read More

Linux – cut

Linux cut command The Linux cut command is a text processing command. This command is used to extract the specific column from a file. You need to define the column number and column delimiter with command. Syntax: cut -d<delemeter> -f<field1,field2,…> filename -d This defines the deleter as coloumn seprator. Defaut column seprater is single space or tab. -f Specify fields (column numbers) to fetch. Example Grep all usernames with there home directory created on a Linux system. The /etc/passwd file contained all users on a Linux system with other details.…

Read More

Linux – ls command

Linux ls command The ls command is used to list files and directories in filesystem. Login to your Linux system and open shell. Syntax ls [OPTION] [FILE] Examples Now type ls and press enter. This will show file names available in the current directory. ls Long Listing Files You can use -l switch to view the long listing of files. ls -l You can also specify the filename to get details for a specific file. ls -l myfile.txt List Hidden Files You can also use the -a switch with ls…

Read More

Bash – Command Arguments

Command Line Arguments in Shell Script Command line arguments are also known as positional parameters. These arguments are specific with the shell script on terminal during the run time. Each variable passed to a shell script at command line are stored in corresponding shell variables including the shell script name. Synatx: ./myscript.sh ARG1 ARG2 ARG3 ARG4 ARG5 ARG6 ARG7 ARG8 ARG9 ARG10 See the below image to understand the command line values and variables. Here ARG1, ARG2 to ARG10 are command line values, which is assigned to corresponding shell variables.…

Read More