How to generate manifest containing all files except particular file name in a folder like the fillowing.
Acctual requirement
4
issue1425.tgz 3096209598
issue1426.TGZ 3096209591
issue1427.ZIP 3096209592
issue1428.zip 3096209593
=> total number of files: 4
file name: issue1425.tgz
size of file: 123333
....
im doing Like this
ls i2*.* |wc -l >>manifest.txt
vdir i2*.* >>manifest.txt
Output in "manifest.txt" from this is
4
-rwxr-Sr-t 1 root root 3096209598 2013-03-28 05:46 issue1425.tgz
-rwxrw-r-- 1 root root 3096209591 2013-03-20 06:46 issue1426.TGZ
-rwxr-Sr-t 1 root root 3096209592 2013-03-28 07:46 issue1427.ZIP
-rwxrw-r-- 1 root root 3096209593 2013-03-20 08:46 issue1428.zip
does any one has the solution to get my exact requirement:
Edit 2:@jarnbjo your command gives me wrong output see the actual sizes of files but its gives me wrongly.
root@aim-deb:/mnt/arch1/batchfiles/siva/20130328094916142/received# vdir
total 108816
drwxrwxrwx 5 1330 sno 4096 2013-03-20 00:30 i23321367
-rw-rw-r-- 1 1330 sno 39934457 2013-03-20 03:20 i23321367.tgz
drwxrwxrwx 5 1330 sno 4096 2013-03-20 00:33 i23321376
-rw-rw-r-- 1 1330 sno 36030069 2013-03-20 03:20 i23321376.tgz
drwxrwxrwx 5 1330 sno 4096 2013-03-20 00:34 i23321436
-rw-rw-r-- 1 1330 sno 35310600 2013-03-20 03:20 i23321436.tgz
-rw-r--r-- 1 root root 69 2013-03-29 00:57 manifest_QAG.txt
-rw-rw-r-- 1 1330 sno 75 2013-03-20 03:20 manifest.txt
root@aim-deb:/mnt/arch1/batchfiles/siva/20130328094916142/received# ls -1s -- block-size=1 i*.* $dir| awk '{print $2"\t"$1}'
i23321367.tgz 39981056
i23321376.tgz 36073472
i23321436.tgz 35352576
root@aim-deb:/mnt/arch1/batchfiles/siva/20130328094916142/received#
Answer:@jarnbjo thanks finally i got it why its happening. block size gives me size if file size on disk not actual size of file. here i want size of file so i can use vdir i*.* $dir| awk '{print $8"\\t"$5}'
If you just want the amount of files and its size, try with this:
ls -1hs $dir
h
stands for human readable s
stands for size 1
(one)just shows the names of files, one on each line. And if you want it to be first name, then size, use:
ls -1hs $dir | awk '{print $2" "$1}'
Edit
From comments, you want it to have size in bytes, so you can do it like:
ls -1s --block-size=1 $dir
Further edit
If you want the dir not to be displayed, you have to cd $dir
previously. There are other ways, but this seems to be the cleanest.
cd $dir; ls -1s --block-size=1 is*.* | awk '{print $2"\t"$1}'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.