I was trying to pipe a TAR after listing a bunch of files. First I tried to list my files according to their date. Like this:
ll /home/dan/test/dir*/file* | grep 2014
-rw-r--r-- 1 root root 0 Jan 2 2014 /home/dan/test/dir1/file1_2014_1
-rw-r--r-- 1 root root 0 Jan 2 2014 /home/dan/test/dir1/file1_2014_10
-rw-r--r-- 1 root root 0 Jan 2 2014 /home/dan/test/dir1/file1_2014_100
-rw-r--r-- 1 root root 0 Jan 2 2014 /home/dan/test/dir1/file1_2014_11
-rw-r--r-- 1 root root 0 Jan 2 2014 /home/dan/test/dir1/file1_2014_12
...
-rw-r--r-- 1 root root 0 Jan 2 2014 /home/dan/test/dir4/file4_2014_97
-rw-r--r-- 1 root root 0 Jan 2 2014 /home/dan/test/dir4/file4_2014_98
-rw-r--r-- 1 root root 0 Jan 2 2014 /home/dan/test/dir4/file4_2014_99
Since the result is a bit poluted, I tried to filter it.
ll /home/dan/test/dir*/file* | grep 2014 | cut -f 2- -d "/" | sed 's/home/\/home/'
/home/dan/test/dir1/file1_2014_1
/home/dan/test/dir1/file1_2014_10
/home/dan/test/dir1/file1_2014_100
/home/dan/test/dir1/file1_2014_11
/home/dan/test/dir1/file1_2014_12
...
/home/dan/test/dir4/file4_2014_97
/home/dan/test/dir4/file4_2014_98
/home/dan/test/dir4/file4_2014_99
which gave just file paths and names. Then I tried to TAR this list using pipe but didn't work out.
So I exported the list to a file
ll /home/dan/test/dir*/file* | grep 2014 | cut -f 2- -d "/" | sed 's/home/\/home/' > list_files_2014.txt
Now, I need to TAR this list.
But when I try it gives me an error:
tar -cvjf test.tar.bz2 -T list_files_2014.txt
tar: Removing leading `/' from member names
/home/dan/test/dir1/file1_2014_1
/home/dan/test/dir1/file1_2014_10
/home/dan/test/dir1/file1_2014_100
/bin/sh: 1: /home/dan/test/dir1/file1_2014_11
bzip2: not found/home/dan/test/dir1/file1_2014_12
/home/dan/test/dir1/file1_2014_13
/home/dan/test/dir1/file1_2014_14
/home/dan/test/dir1/file1_2014_15
/home/dan/test/dir1/file1_2014_16
/home/dan/test/dir1/file1_2014_17
/home/dan/test/dir1/file1_2014_18
/home/dan/test/dir1/file1_2014_19
/home/dan/test/dir1/file1_2014_2
/home/dan/test/dir1/file1_2014_20
/home/dan/test/dir1/file1_2014_21
/home/dan/test/dir1/file1_2014_22
/home/dan/test/dir1/file1_2014_23
/home/dan/test/dir1/file1_2014_24
/home/dan/test/dir1/file1_2014_25
/home/dan/test/dir1/file1_2014_26
tar: test.tar.bz2: Cannot write: Broken pipe
tar: Child returned status 127
tar: Error is not recoverable: exiting now
Can anyone help me out? Thanks