Cut Rows
How do I cut rows out of my listing?
Here is my current code: ls-l1S | cut –d’ ‘ –f8 | cut -d' ' I need the largest file to be the only one remaining, (ie: cutting all other files/listings out of the listing) Currently it has CIS350 MyNetworkingClass MyNetworkingClass^C MyNetworking MyNetworking^C It needs to just display the first one (CIS350) Thanks! |
See man 1 head. To output only the first line, and skip the others, use head -n 1
|
It worked :-) thanks!
|
You really should keep follow-up questions in the same thread as the original. Start a new thread when you have a completely new topic to discuss.
I just posted a reply in your last thread about this: http://www.linuxquestions.org/questi...e-size-913510/ Also, please use [code][/code] tags around your code, to preserve formatting and to improve readability. Thanks. Anyway, another trick is to use the read built-in. Code:
read file < <( ls 1S ) Note also that this assumes that the filename you want sits on the first line. As the link I gave in the other thread points out, newlines are legal characters in *nix file names, so it is possible for it to only grab a partial file name. The technique I posted before doesn't have that problem. |
All times are GMT -5. The time now is 04:03 PM. |