How to sort files in Bash.
Display contents
$ cat file.txt
bbb
aaa
ccc
kkk
uuu
ppp |
Sort
$ sort file.txt
aaa
bbb
ccc
kkk
ppp
uuu |
Sort in place
$ sort -o file.txt file.txt $ cat file.txt aaa bbb ccc kkk ppp uuu |
cloud engineer
How to sort files in Bash.
Display contents
$ cat file.txt
bbb
aaa
ccc
kkk
uuu
ppp |
$ cat file.txt bbb aaa ccc kkk uuu ppp
Sort
$ sort file.txt
aaa
bbb
ccc
kkk
ppp
uuu |
$ sort file.txt aaa bbb ccc kkk ppp uuu
Sort in place
$ sort -o file.txt file.txt $ cat file.txt aaa bbb ccc kkk ppp uuu |
$ sort -o file.txt file.txt $ cat file.txt aaa bbb ccc kkk ppp uuu
Find the biggest files in the current directory. Sort by from large to small. Display only the top 20. Display in human readable format.
find -type f -exec du -Sh {} + | sort -rh | head -n 20 |
find -type f -exec du -Sh {} + | sort -rh | head -n 20
Here’s how to reverse sort WP_Query. Order by ID. Reverse sort by ASC intead of DESC.
$args = array ( 'cat' => 8, 'year' => $year, 'orderby' => 'ID', 'order' => 'ASC', 'posts_per_page' => -1, 'paged' => $paged, 's' => $searchterm ); $category_posts = new WP_Query($args); |
$args = array ( 'cat' => 8, 'year' => $year, 'orderby' => 'ID', 'order' => 'ASC', 'posts_per_page' => -1, 'paged' => $paged, 's' => $searchterm ); $category_posts = new WP_Query($args);