Command Help
I need a command that will ouput a certain line in a text file.
Not a line with known string aka grep. I just want it to spit out say line 56 of the file. Any ideas? I've googled, searched here, etc. and can't find a thing. |
|
Try these!!!
Give a try following commands
cat more less |
Hi.
There might be an easier way to do this. But this works for me. This is to display the 8th line of my /etc/passwd file for example cat -n /etc/passwd | grep 8 In your case you could do cat -n /your/file.txt | grep 56 Again, there is probably an easier way to do it, but I've always used this because I've never found another way :) cat -n that will output and number each line, grep grabs what ever you enter after it. So it is basically numbering the output lines (not changing the file at all) and then showing the whole line you need. Obviously just ignore the number it outputs for you. >Craig :) |
I like the workaround that "TheRealDeal" has proposed. But one concern that I have is if the file that you are attempting to grep through is a file that has a lot of numbers in it, you may well get a lot of information that you do not want.
Another option that you may want to try (I admit it is abit of a kludge, but it seems to work). To display the 10th line of the /etc/host file: tail +10 /etc/hosts | head -1 With this method you should be able to avoid false positives. |
Hey thanks alot kvedaa, that worked great!
Thanks to everyone else for giving it a go as well. |
Nice one kvedaa, I like it!! I hadn't thought about the file having numbers in it :)
|
All times are GMT -5. The time now is 06:17 AM. |