Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Loop for file merging in a folder Post 302885445 by sea on Sunday 26th of January 2014 10:27:57 AM
Old 01-26-2014
The try with array
Code:
#!/bin/sh
#
#	Vars
#
	FZ=(*)
	ZC=0 # Z Counter
	I=1
	THESE=""
	echo ${FZ[@]}
#
#	Action
#
	mkdir output

	for C in 2 3 4
	do
		for Z in ${FZ[@]}
		do
			THESE=$Z

			while [[ $I -gt $C ]]
			do
				NUM=$[ $ZC + $I ]
				THESE+=" ${FZ[$NUM]}"
				let I++
			done
			str=$(echo $THESE|sed s,' ','-',g)
			cat $THESE|sort -u > output/$str

			let ZC++
			I=1
			THESE=""
		done
	done

Edit2:
looked right, but was wrong

Last edited by sea; 01-26-2014 at 11:44 AM..
This User Gave Thanks to sea For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parse the .txt file for folder name and FTP to the corrsponding folder.

Oracle procedure create files on UNIX folder on a regular basis. I need to FTP files onto windows server and place the files, based on their name, in the corresponding folders. File name is as follows: ccyymmddfoldernamefile.txt; Folder Name length could be of any size; however, the prefix and... (3 Replies)
Discussion started by: MeganP
3 Replies

2. Shell Programming and Scripting

File Management: How do I move all JPGS in a folder structure to a single folder?

This is the file structure: DESKTOP/Root of Photo Folders/Folder1qweqwasdfsd/*jpg DESKTOP/Root of Photo Folders/Folder2asdasdasd/*jpg DESKTOP/Root of Photo Folders/Folder3asdadfhgasdf/*jpg DESKTOP/Root of Photo Folders/Folder4qwetwdfsdfg/*jpg DESKTOP/Root of Photo... (4 Replies)
Discussion started by: guptaxpn
4 Replies

3. Shell Programming and Scripting

Shell script for merging lines in a loop

Dear All, I need a script to merge lines of an input file in a loop, please guide me for the script or one liner(awk, sed, tr, shell, perl). I/P File------------------------- APaul,,,,SDH,,23,,,PPH,,2 ,,,,KKH,,19,,,MMH,,12, ,,,,CCH,,22,,,MNH,,19, ,,,,TCH,,55,,,NNH,,67,... (3 Replies)
Discussion started by: ashis.tewari
3 Replies

4. Shell Programming and Scripting

File in a folder and loop until time

Hi All, I am stuck with this requirement. My requirement is that a job will run daily at anytime before and would look for a file named filename.txt in a folder and mv to a different folder and if not found until 9 A.M it will exit with a success code. Now I did the follwing ..but there... (8 Replies)
Discussion started by: RubinPat
8 Replies

5. Shell Programming and Scripting

Merging folder of files according to name and contents.

I have absolutely no idea how to do this and everything I have done doesn't even come close. Here's the scenario: There are a number of files in a folder named in this manner: agd.txt stv.txt frk.txt dqp.txt There is also a series of other files in the same folder with like file... (5 Replies)
Discussion started by: Trapper
5 Replies

6. Shell Programming and Scripting

Loop through text file > Copy Folder > Edit XML files in bulk?

I have a text file which contains lines in this format - it contains 105 lines in total, but I'm just putting 4 here to keep it short: 58571,east_ppl_ppla_por 58788,east_pcy_hd_por 58704,east_pcy_ga_por 58697,east_pcy_pcybs_por It's called id_key.txt I have a sample folder called... (9 Replies)
Discussion started by: biscuitcreek
9 Replies

7. Shell Programming and Scripting

File merging based on different counter loop

hello, File 1 main Group sub group MIT VAR_1D_DATA_TYPE 23-03-2012 MIT VAR_1D_DATA_TYPE 22-03-2012 MIT VAR_10D_DATA_TYPE 23-03-2012 MIT VAR_10D_DATA_TYPE 22-03-2012 MIT ... (0 Replies)
Discussion started by: manas_ranjan
0 Replies

8. Shell Programming and Scripting

For loop to read folder which are not under processing

Hi, I want to read folders which do not have a file "processing" in a for loop ordered by timestamp. Currently im doing like this. Like cd /home/working for i in `ls -c1` do some command... done I want to exclude folders which have that "processing" file. The directory... (2 Replies)
Discussion started by: chetan.c
2 Replies

9. Shell Programming and Scripting

For loop for number of files in a folder

Hi All, Need a for loop which should run for number of files in a folder and should pass the file name as parameter to another shell script for each loop. Please help me. Thanks. (2 Replies)
Discussion started by: chillblue
2 Replies

10. Shell Programming and Scripting

Merging two columns from two files with similar names into a loop

I have two files like this: fileA.net A B C fileA.dat 1 2 3 and I want the output output_expected A 1 B 2 C 3 I know that the easier way is to do a paste fileA.net fileA.dat, but the problem is that I have 10,000 couple of files (fileB.net with fileB.dat; fileC.net with... (3 Replies)
Discussion started by: valente
3 Replies
TRACEROUTE(1)                                                      User Commands                                                     TRACEROUTE(1)

NAME
traceroute - Trace the route to a host SYNOPSIS
traceroute [OPTION...] HOST DESCRIPTION
Print the route packets trace to network host. -f, --first-hop=NUM Set initial hop distance, that is the time-to-live. -g, --gateways=GATES List of gateways for loose source routing. -I, --icmp Use ICMP ECHO as probe. -m, --max-hop=NUM Set maximal hop count (default is 64). -M, --type=METHOD Use METHOD (icmp or udp) for traceroute operations, defaulting to udp. -p, --port=PORT Use destination PORT port (default is 33434). -q, --tries=NUM Send NUM probe packets per hop (default is 3). --resolve-hostnames Resolve hostnames. -t, --tos=NUM Set type of service (TOS) to NUM. -w, --wait=NUM Wait NUM seconds for response (default is 3). -?, --help Give this help list. --usage Give a short usage message. -V, --version Print program version. GNU inetutils 2015-05-15 TRACEROUTE(1)
All times are GMT -4. The time now is 08:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy