Please help with tarball script
The following script is supposed to look at a list of files and folders and tar them all up. Ofcourse you have to strip off everything to the left of the file or folder to tar only that object. My problem is that when I do that my script no longer knows how to find the file or folder. Is there a way of saving in a variable the location of the object you want to tar and have it passed to the for loop with each iteration. I'm trying to stay away from nested loops. Thanks in advance for your help.
#!/bin/bash
for p in `cat /data/results/filelist`
do
i=`echo $p | awk 'BEGIN{FS="/"}{print $NF}'`
cd $p && tar czf ../$i.tar.gz $i
done
filelist below:
/data/results/solid0155/solid0155_20090918_2x35_LMP_FC2
/data/results/RegressionDriver/CaseManager/tests_era2/cases/performance/155_2x35
_FC2_run_outputs_tillSam
/share/reference/genomes/chromFa/hg18_validated.fasta
/data/results/README
|