How to read particular line in a file in unix?Shell script or command

How to read particular line in file in Unix. 

We can do that writing a small shell script or Little unix command

Say I have a file named a.txt with some content

bash-3.00$ cat a.txt
Info : === insert : nothing  ON  Sub-Elt Group  ( ~NOC Reporting ) (exists)
Info : === insert : nothing  ON Link SEGP/TZ ( Greenwich Mean Time  CME Permanent ) (exists)
Info : === insert : nothing  ON  Sub-Elt Group  ( ~kb ) (exists)
Info : === insert : INSERT ON Link SEGP/TZ ( Greenwich Mean Time  kb ) (does not exist)
Info : === Update Histo : 0

Now if i want to read the 3rd line from this file we can do the same using 2 ways

bash-3.00$ head -n 3 a.txt | tail -1
Info : === insert : nothing  ON  Sub-Elt Group  ( ~kb ) (exists)

bash-3.00$sed -n '20{;p;q;}' file
Info : === insert : nothing  ON  Sub-Elt Group  ( ~kb ) (exists)


0 comments to "How to read particular line in a file in unix?Shell script or command"

Post a Comment

Whoever writes Inappropriate/Vulgar comments to context, generally want to be anonymous …So I hope U r not the one like that?
For lazy logs, u can at least use Name/URL option which doesn’t even require any sign-in, The good thing is that it can accept your lovely nick name also and the URL is not mandatory too.
Thanks for your patience
~Krishna(I love "Transparency")

Popular Posts

Enter your email address:

Buffs ...

Tags


Powered by WidgetsForFree