Sponsored Content
Top Forums Shell Programming and Scripting Help with grouping and zipping Post 303000168 by RavinderSingh13 on Wednesday 5th of July 2017 01:50:57 PM
Old 07-05-2017
Hello paul1234,

It is little bit not clear, so I am considering that your folders named 1,2,3,4 are present in path /dir1/FXX/, if this is the case then following may help you in same.
Code:
awk -F',' 'NR>1{A[$4]=A[$4]?A[$4]","$3:$3} END{for(i in A){num=split(A[i], array,",");for(j=1;j<=num;j++){print "mv ","/"array[j],"/"array[j]"/../"i};print "zip ",i".zip",i}}'   Input_file

Above will print the commands, so either you could see the output if it looks good to you, you could add | sh after above command or if you have doubt on any command try one of the command printed(hope in a non-live environment or in a test directory first), if works fine then also you could add | sh at end of the above command please. Let me know how it goes then.

Sample output will be as follows for above command too.
Code:
mv  /dir1/FXX/Y25 /dir1/FXX/Y25/../4
zip  4.zip 4
mv  /dir1/FXX/F19 /dir1/FXX/F19/../1
mv  /dir1/FXX/F20 /dir1/FXX/F20/../1
zip  1.zip 1
mv  /dir1/FXX/F23 /dir1/FXX/F23/../2
mv  /dir1/FXX/C25 /dir1/FXX/C25/../2
mv  /dir1/FXX/X25 /dir1/FXX/X25/../2
zip  2.zip 2
mv  /dir1/FXX/A23 /dir1/FXX/A23/../3
mv  /dir1/FXX/Z25 /dir1/FXX/Z25/../3
zip  3.zip 3

EDIT: Or try following one too, if you want to have complete path for zipping folders also.
Code:
awk -F',' 'NR>1{A[$4]=A[$4]?A[$4]","$3:$3} END{for(i in A){num=split(A[i], array,",");for(j=1;j<=num;j++){print "mv ","/"array[j],"/"array[j]"/../"i};print "zip ",i".zip","/"array[num]"/../"}}'  Input_file

PS: Not tested this command, so only above explanation.

Thanks,
R. Singh

Last edited by RavinderSingh13; 07-05-2017 at 03:46 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Zipping

Hi In unix i want to zip the files in a directory excluding *.dmp, *.log, *.lst, *.out files in that directory. pls let me know what command to use. $zip ........ ? Thanks (1 Reply)
Discussion started by: dreams5617
1 Replies

2. Shell Programming and Scripting

zipping files

Dear Experts, I need a script which will zipped the files older than 2 days. but i dont want to use find . * -mtime 2. Is there is any other method to achive this task. i will ececute the script daily. Regards, (3 Replies)
Discussion started by: shary
3 Replies

3. UNIX for Dummies Questions & Answers

Zipping files?

how would i zip a file? what does zip mean? (4 Replies)
Discussion started by: trob
4 Replies

4. Shell Programming and Scripting

Zipping and moving

Hi, I have got the script which find out the file that was modified 3 days ago now i want that all the files which fall into this category to be get zipped and then send to another directory...plz can u suggest me for that or any commands (18 Replies)
Discussion started by: SARAL SAXENA
18 Replies

5. UNIX for Dummies Questions & Answers

Help With zipping a file

Hi I need to zip a file and move it into another folder along with the timestamp. The orginal file must be removed from the source directory Source : folder1/source12.txt folder2 After zipping Folder1/Folder2/source12.zip Any help will be greatly appreciarted ... (5 Replies)
Discussion started by: akshay01987
5 Replies

6. UNIX for Dummies Questions & Answers

Zipping files

Hi All, I have a scenario where in am using uuencode to send a txt file as an excel to end users( email attachment).I have 7 different files and these files are sent as emails 7 times... So my question is, can i not zip all the 7 files at once and attach those files in a single... (9 Replies)
Discussion started by: saggiboy10
9 Replies

7. Shell Programming and Scripting

Zipping files

Hi Guys, The script below works but it creates a zip folder under 123_arch.zip -- test1 -- orig1.txt -- orig2.txt -- orig3.txt -- orig4.txt I don't want the sub directory test1 but everything under the base *arch name I can not create a long name with... (4 Replies)
Discussion started by: GaryP1973
4 Replies

8. Shell Programming and Scripting

Zipping without extension

I currently have a code that find and zip all files in current folder and zip it, the problem is the name of the zip will include the extension as well and I don't want it. for ex: Volvo-red.swf -> Volvo-red.swf.zip find . -maxdepth 1 -type f ! -name ".*" -exec bash -c 'zip -r "$0.zip"... (6 Replies)
Discussion started by: Frozen77
6 Replies

9. Post Here to Contact Site Administrators and Moderators

Help with Grouping and zipping folders

Hi can you please help with the below ? source file: Column1,Column2,Column3,Column4 abc,123,dir1/FXX/F19,1 abc,123,dir1/FXX/F20,1 abc,123,dir1/FXX/F23,2 abc,123,dir1/FXX/C25,2 abc,123,dir1/FXX/X25,2 abc,123,dir1/FXX/A23,3 abc,123,dir1/FXX/Z25,3 abc,123,dir1/FXX/Y25,4 I want to... (1 Reply)
Discussion started by: paul1234
1 Replies

10. UNIX for Beginners Questions & Answers

Zipping

Good Morning, I'd like to archive an old user's files in the home directory on Solaris 9 Will this work? cd home tar -zcvf jsmitharchive.tar.gz jsmith/ ---------- Post updated at 09:37 AM ---------- Previous update was at 09:33 AM ---------- Also- is the last /necessary (after... (4 Replies)
Discussion started by: Stellaman1977
4 Replies
PAPS(1) 						      General Commands Manual							   PAPS(1)

NAME
paps - UTF-8 to PostScript converter using Pango SYNOPSIS
paps [options] files... DESCRIPTION
paps reads a UTF-8 encoded file and generates a PostScript language rendering of the file. The rendering is done by creating outline curves through the pango ft2 backend. OPTIONS
These programs follow the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below. --landscape Landscape output. Default is portrait. --columns=cl Number of columns output. Default is 1. Please notice this option isn't related to the terminal length as in a "80 culums terminal". --font=desc Set the font description. Default is Monospace 12. --rtl Do right to left (RTL) layout. --paper ps Choose paper size. Known paper sizes are legal, letter and A4. Default is A4. Postscript points Each postscript point equals to 1/72 of an inch. 36 points are 1/2 of an inch. --bottom-margin=bm Set bottom margin. Default is 36 postscript points. --top-margin=tm Set top margin. Default is 36 postscript points. --left-margin=lm Set left margin. Default is 36 postscript points. --right-margin=rm Set right margin. Default is 36 postscript points. --gutter-width=gw Set gutter width. Default is 40 postscript points. --help Show summary of options. --header Draw page header for each page. --markup Interpret the text as pango markup. --lpi Set the lines per inch. This determines the line spacing. --cpi Set the characters per inch. This is an alternative method of specifying the font size. --stretch-chars Indicates that characters should be stretched in the y-direction to fill up their vertical space. This is similar to the texttops behaviour. AUTHOR
paps was written by Dov Grobgeld <dov.grobgeld@gmail.com>. This manual page was written by Lior Kaplan <kaplan@debian.org>, for the Debian project (but may be used by others). April 17, 2006 PAPS(1)
All times are GMT -4. The time now is 12:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy