Page 1 of 1

getting rid of absolute path while zipping files in unix

Posted: Tue Mar 27, 2012 9:54 am
by mekrreddy
Hi I am using below unix command to zip the reject files in DirReject directory which have record (line) count >1, It works fine but the files are having their absolute path along with them, Can you please help me get rid of the absolute path and have just file name.

zip DirReject/Rejects_zip `wc -l DirReject/*.Rej| awk '$1>1{print}'|awk '$2 !~ /total$/'| awk '{print $2}'`

files in my Rejects_zip file are : /home/dir1/dir2/xxx1.Rej
/home/dir1/dir2/xxx2.Rej

But I would like to see : xxx1.Rej
xxx2.Rej

Thanks a lot in advance!!

-reedy

Posted: Tue Mar 27, 2012 10:47 am
by chulett
First cd to the directory in question, then zip. In other words, zip using a relative path.