Ubuntu: Up and Running by Nixon Robin

Ubuntu: Up and Running by Nixon Robin

Author:Nixon, Robin [Robin Nixon]
Language: eng
Format: epub
Tags: COMPUTERS / Operating Systems / Linux
ISBN: 9781449390730
Publisher: O'Reilly Media
Published: 2010-04-11T16:00:00+00:00


Figure 7-15. The result of displaying files.txt

But what if you want to know which files and folders were created first? The answer would be to sort them by column 6, and you could use this command to do it:

ls -al | sort -k6 > ~/files.txt

Redirecting Input

If you need to keep the file sorted alphabetically but still wish to sometimes view the lines in date order, you can issue the following command on it instead:

sort -k6 < ~/files.txt

This opens up files.txt, reads it in, and passes its contents to the command immediately preceding the < symbol.

You could even extend that to use the less command by adding the | operator:

sort -k6 < ~/files.txt | less

This works because the > and < operators work on files and devices, whereas the | operator creates pipes between commands. Therefore, sort -k6 < ~/files.txt is seen as a complete command in its own right, the output of which can be displayed or, as in this case, piped to another command.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.