Sponsored Content
Full Discussion: Insert FileName to headers
Top Forums Shell Programming and Scripting Insert FileName to headers Post 302925937 by ali.seifaddini on Thursday 20th of November 2014 10:14:01 AM
Old 11-20-2014
Quote:
Originally Posted by RudiC
Try (untested):
Code:
awk 'BEGIN          {OFS = "\t"; HD=OFS OFS}
     FNR == 1       {HD=HD OFS FILENAME}
     FNR == NR      {a[$2 " " $3] = $1; next}
                    {a[$2 " " $3] = (a[$2 " " $3] OFS $1)}
     END            {print HD
                     for(x in a) print (x OFS a[x])}
    ' *  > Result.csv

Thank you for your responding. But your code didn`t work well.

the result:
Code:
SG1130113000247.CAPNFXS.csv.csv    SG1130113001247.CAPNFXT.csv.csv     SG1130113002247.CAPNFXU.csv.csv
76,3.62945,101.54361,2.000 76,3.62945,101.54862,2.000     80,3.61447,101.55863,2.000
         75,3.62945,101.54361,2.000    75,3.62945,101.54862,2.000     75,3.62945,101.55362,2.000    76,3.62945,101.55863,2.000     76,3.62446,101.54361,2.000    76,3.62446,101.54862,2.000     76,3.62446,101.55362,2.000    78,3.62446,101.55863,2.000     77,3.61946,101.54361,2.000    77,3.61946,101.54862,2.000     77,3.61946,101.55362,2.000    81,3.61946,101.55863,2.000     77,3.61447,101.54361,2.000    78,3.61447,101.54862,2.000     78,3.61447,101.55362,2.000    80,3.61447,101.55863,2.000     76,3.62945,101.54361,2.000    76,3.62945,101.54862,2.000     75,3.62945,101.55362,2.000    73,3.62945,101.55863,2.000     76,3.62446,101.54361,2.000    77,3.62446,101.54862,2.000     77,3.62446,101.55362,2.000    76,3.62446,101.55863,2.000     77,3.61946,101.54361,2.000    78,3.61946,101.54862,2.000     78,3.61946,101.55362,2.000    79,3.61946,101.55863,2.000     77,3.61447,101.54361,2.000    78,3.61447,101.54862,2.000     78,3.61447,101.55362,2.000    80,3.61447,101.55863,2.000     74,3.62945,101.54361,2.000    74,3.62945,101.54862,2.000     74,3.62945,101.55362,2.000    74,3.62945,101.55863,2.000     74,3.62446,101.54361,2.000    74,3.62446,101.54862,2.000     74,3.62446,101.55362,2.000    76,3.62446,101.55863,2.000     75,3.61946,101.54361,2.000    75,3.61946,101.54862,2.000     75,3.61946,101.55362,2.000    78,3.61946,101.55863,2.000     75,3.61447,101.54361,2.000    76,3.61447,101.54862,2.000     76,3.61447,101.55362,2.000    79,3.61447,101.55863,2.000
SG1130113001247.CAPNFXT.csv.csv SG1130113002247.CAPNFXU.csv.csv     SG1130113000247.CAPNFXS.csv.csv

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Insert date/time within a filename

Hi Guys, I need to script the renaming of files as followins: files: firstjd secondjo thirdjv My script needs to insert the date/time infront of the last 2 characters of the filenames above, any ideas greatly received :) the letters before the last 2 characters could change, I'm only... (7 Replies)
Discussion started by: cooperman
7 Replies

2. Shell Programming and Scripting

insert filename into file using SED (or AWK)

Hi, I would like to insert a file's filename into the first line of that file - for a batch of files. Is this possible using SED? Thanks in advance. (2 Replies)
Discussion started by: USER#5
2 Replies

3. Shell Programming and Scripting

Remove text between headers while leaving headers intact

Hi, I'm trying to strip all lines between two headers in a file: ### BEGIN ### Text to remove, contains all kinds of characters ... Antispyware-Downloadserver.com (Germany)=http://www.antispyware-downloadserver.c om/updates/ Antispyware-Downloadserver.com #2... (3 Replies)
Discussion started by: Trones
3 Replies

4. Shell Programming and Scripting

Merging of files with different headers to make combined headers file

Hi , I have a typical situation. I have 4 files and with different headers (number of headers is varible ). I need to make such a merged file which will have headers combined from all files (comman coluns should appear once only). For example - File 1 H1|H2|H3|H4 11|12|13|14 21|22|23|23... (1 Reply)
Discussion started by: marut_ashu
1 Replies

5. Shell Programming and Scripting

Filename from splitting files to have the same filename of the original file with counter value

Hi all, I have a list of xml file. I need to split the files to a different files when see the <ko> tag. The list of filename are B20090908.1100-20090908.1200_CDMA=1,NO=2,SITE=3.xml B20090908.1200-20090908.1300_CDMA=1,NO=2,SITE=3.xml B20090908.1300-20090908.1400_CDMA=1,NO=2,SITE=3.xml ... (3 Replies)
Discussion started by: natalie23
3 Replies

6. Shell Programming and Scripting

insert filename into each line of multiple files

I need to insert <filename + comma> into each line of multiple files. Any idea how to script that? Regards, Manu (5 Replies)
Discussion started by: linux.yahoo
5 Replies

7. Shell Programming and Scripting

BASH Batch renaming insert additional zero into filename

Hi all, Wondering how this could be accomplished........ a directory contains sequentially numbered files from fw01 to fw999. How would I insert an additional zero so that the directory lists these files in a proper manner? (i.e. all double digit files from fw01 to fw99 would become... (3 Replies)
Discussion started by: putter1900
3 Replies

8. Shell Programming and Scripting

insert part of a filename in a textfile

Hi All, I've got a textfile that i've stripped and edited using sed and want to insert part of the filename (original filename consists of: fw0204.txt.ncat_report.txt) but there are multiple files being delivered by an application to the data directory The part of the filename that I need to... (0 Replies)
Discussion started by: etquart
0 Replies

9. Shell Programming and Scripting

Insert Filename into Multiple Files

Hi, We have a folder that has files in the following structure abc.sql def.sql efg.sql . . . xyz.sql I have to find a certain string (say "test") in each file and replace it with the name of the file. For eg. if "test" is present in abc.sql, I want to replace it with "test abc". If... (8 Replies)
Discussion started by: jerome_rajan
8 Replies

10. UNIX for Beginners Questions & Answers

Insert the line number from text file to filename output

Hi everyone :) I have a file "words.txt" containing hundreds of lines of text. Each line contains a slogan. Using the code below i am able to generate an image with the slogan text from each line. The image filename is saved matching the last word on each line. Example: Line 1: We do... (2 Replies)
Discussion started by: martinsmith
2 Replies
GIT-MERGE-INDEX(1)						    Git Manual							GIT-MERGE-INDEX(1)

NAME
git-merge-index - Run a merge for files needing merging SYNOPSIS
git merge-index [-o] [-q] <merge-program> (-a | [--] <file>*) DESCRIPTION
This looks up the <file>(s) in the index and, if there are any merge entries, passes the SHA-1 hash for those files as arguments 1, 2, 3 (empty argument if no file), and <file> as argument 4. File modes for the three files are passed as arguments 5, 6 and 7. OPTIONS
-- Do not interpret any more arguments as options. -a Run merge against all files in the index that need merging. -o Instead of stopping at the first failed merge, do all of them in one shot - continue with merging even when previous merges returned errors, and only return the error code after all the merges. -q Do not complain about a failed merge program (a merge program failure usually indicates conflicts during the merge). This is for porcelains which might want to emit custom messages. If git merge-index is called with multiple <file>s (or -a) then it processes them in turn only stopping if merge returns a non-zero exit code. Typically this is run with a script calling Git's imitation of the merge command from the RCS package. A sample script called git merge-one-file is included in the distribution. ALERT ALERT ALERT! The Git "merge object order" is different from the RCS merge program merge object order. In the above ordering, the original is first. But the argument order to the 3-way merge program merge is to have the original in the middle. Don't ask me why. Examples: torvalds@ppc970:~/merge-test> git merge-index cat MM This is MM from the original tree. # original This is modified MM in the branch A. # merge1 This is modified MM in the branch B. # merge2 This is modified MM in the branch B. # current contents or torvalds@ppc970:~/merge-test> git merge-index cat AA MM cat: : No such file or directory This is added AA in the branch A. This is added AA in the branch B. This is added AA in the branch B. fatal: merge program failed where the latter example shows how git merge-index will stop trying to merge once anything has returned an error (i.e., cat returned an error for the AA file, because it didn't exist in the original, and thus git merge-index didn't even try to merge the MM thing). GIT
Part of the git(1) suite Git 1.8.5.3 01/14/2014 GIT-MERGE-INDEX(1)
All times are GMT -4. The time now is 04:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy