How to use the head and tail commands | Linux commands Part 5
The Data Guy
#head #tail #bash #terminal #basic #command #linux In linux, getting a portion of a text from a Input file is Very common and to perform such operation we have two command i.e. head and tail command
As their name implies , head command is use to get the first part of the file , while the tail command is use to get the last part of the file
Intro-(0:00) explanation-(0:16) head-(1:10) tail-(5:05) endscreen-(10:55)
▶️head [first part] To get default output : head textfile to get first n specified line : head -n9 textfile [first 9 lines will be printed] to get all lines except last x lines : head -n-x [x can be any const. 1,2,3] to get first c specified character : head -c7 [print first 7 character] to get output from multiple files : head file file2 [will print fisrt default no. of lines from 1st file as well as 2nd file]
▶️tail [last [part]
To get default output : tail textfile to get last n specified line : tail -n9 textfile [last 9 lines will be printed] to get the lines starting from x till last : head -n+x [x can be any const. 1,2,3] to get last c specified character : head -c7 [print last 7 character] to get output from multiple files : tail file file2 [will print last default no. of lines from 1st file as well as 2nd file] to get output from files that are currently changing : tail -f filename
scripts used
to create a file of 100 lines consisting from 1 to 100 digits used in video : https://github.com/shazx06/youtube/blob/main/1stfile.md
to create a script to apped the content to the end of the file file used in the video :https://github.com/shazx06/youtube/blob/main/2ndfile.md
▶️Basic commands in Linux Part 1 : https://www.youtube.com/watch?v=K3qGtbyc0Ck ▶️Basic commands in Linux part 3 : https://www.youtube.com/watch?v=eq0o49qKhCg
🤖Join our discord server : https://discord.io/thedataguy
Follow shazib on : ✅GitHub (https://github.com/shazx06)
✅Linked In (https://www.linkedin.com/in/md-shazib ...)
📌I'm DeTeam Content Creator. If you would like to join our community to grow your channel or just have a chat with us then use this link: https://invite.gg/DeTeam –––––––––––––––––––––––––––––– Fragments by Nomyn https://soundcloud.com/nomyn Creative ... https://www.youtube.com/watch?v=K7ki2z23qlE
19730797 Bytes