How to merge result in shellscript

Issue

I want to merge results in shellscript.

ls -lrt
-rw-r--r--  1 cu  staff  11 Jul 23 23:57 aaa
-rw-r--r--  1 cu  staff   8 Jul 24 00:12 bbb
-rw-r--r--  1 cu  staff  33 Jul 24 02:31 ccc
-rw-r--r--  1 cu  staff  75 Jul 24 02:32 ddd

cksum `ls`
1108326690 11 aaa
1221844548 8 bbb
1213522119 33 ccc
3248460215 75 ddd

↓

-rw-r--r--  1 cu  staff  11 Jul 23 23:57 aaa 1108326690 11 aaa
-rw-r--r--  1 cu  staff   8 Jul 24 00:12 bbb 1221844548 8 bbb
-rw-r--r--  1 cu  staff  33 Jul 24 02:31 ccc 1213522119 33 ccc
-rw-r--r--  1 cu  staff  75 Jul 24 02:32 ddd 3248460215 75 ddd

I tried the command below but failed.
(ls -l; cksum ls) | xargs

Please show me kindly how to merge these results.

Solution

This may be what you want:

paste  <(ls -lrt *) <(cksum `ls -rt`)

Note that this is intended to be used interactively (not inside a script) and may not work properly if filenames contain "weird" characters, or the current directory has subdirectories.

Answered By – M. Nejat Aydin

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published