Print line number X of a file (in shell)
I didn't think I need it a while ago so I excuse me for another topic.
Is there a way to print line number X of a certain file. For example: file "file" has 3 lines: hello abc hi Is there a simple command to print say, the second line of file "file": abc |
If nothing else you could just do:
Code:
head -n $num $file | tail -n 1 |
Assume you want to print just line 29 ---
this is one way to do it: Code:
head -29 myfile | tail -1 |
Thanks. It's an odd way, but I suppose this is how it's usually/(supposed to be) done. XD
|
There's also sed:
Code:
sed -n 17p yourfile.txt |
All times are GMT -5. The time now is 02:28 AM. |