Sponsored Content
Top Forums Shell Programming and Scripting Desired output.txt for reading txt file using awk? Post 302934367 by RavinderSingh13 on Friday 6th of February 2015 10:57:00 AM
Old 02-06-2015
Hello emily,

Could you please try following code and let me know if this helps.
Code:
awk -vs="'" -vs1="infile=[" -vs2="]" -vs3="infile.append(" -vs4=")" '(NR==1){print s1 s $2 s s2} (NR>1){print s3 s $2 s s4}'  Input_file

Output will be as follows.
Code:
infile=['/abcd/directory/sub_directory/Samsung/150206_135953/0000/L1ITMBLT_54.root']
infile.append('/abcd/directory/sub_directory/Samsung/150206_135953/0000/L1ITMBLT_93.root')
infile.append('/abcd/directory/sub_directory/Samsung/150206_135953/0000/L1ITMBLT_74.root')
infile.append('/abcd/directory/sub_directory/Samsung/150206_135953/0000/L1ITMBLT_171.root')
infile.append('/abcd/directory/sub_directory/Samsung/150206_135953/0000/L1ITMBLT_112.root')
infile.append('/abcd/directory/sub_directory/Samsung/150206_135953/0000/L1ITMBLT_107.root')
infile.append('/abcd/directory/sub_directory/Samsung/150206_135953/0000/L1ITMBLT_18.root')

NOTE: Considering your Input_file doesn't have spaces in starting.


Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reading Characters from txt file

Hello, I am new to shell scripting, and I am trying to create a script that reads an input like the following firstname:lastname:age firstname:lastname:age firstname:lastname:age in a text file. I have a 2 part question. First how do I open the file in a shell script. And then how can... (7 Replies)
Discussion started by: TexasGuy
7 Replies

2. Shell Programming and Scripting

Sorting problem "sort -k 16,29 sample.txt > output.txt"

Hi all, Iam trying to sort the contents of the file based on the position of the file. Example: $cat sample.txt 0101020060731 ## Header record 1c1 Berger Awc ANP20070201301 4000.50 1c2 Bose W G ANP20070201609 6000.70 1c2 Andy CK ANP20070201230 28000.00... (3 Replies)
Discussion started by: ganapati
3 Replies

3. Shell Programming and Scripting

reading the txt file

hi to all im having some 20,000 files in that im having some contents say the tabulation of biophysics lab readings ... and i want read tat file and look into tat wether a number say -18.90 is there r not .. and if there print tat no wit file name beside thank you:D (1 Reply)
Discussion started by: maximas
1 Replies

4. UNIX for Dummies Questions & Answers

Binary txt file received when i use uuencode to send txt file as attachment

Hi, I have already read a lot of posts on sending attachments in unix...but none of them were of help for my problem...so here goes.. i wanna attach a text file and send to a mail id..used the following code : uuencode "$File1" "$File1" ;|mail -s "$Mail_sub" abc@abc.com it works... (2 Replies)
Discussion started by: ash22
2 Replies

5. Shell Programming and Scripting

AWK CSV to TXT format, TXT file not in a correct column format

HI guys, I have created a script to read 1 column in a csv file and then place it in text file. However, when i checked out the text file, it is not in a column format... Example: CSV file contains name,age aa,11 bb,22 cc,33 After using awk to get first column TXT file... (1 Reply)
Discussion started by: mdap
1 Replies

6. Programming

Reading a particular line from a .txt file

Hi, I have a .txt file which contains the x, y and z co-ordinates of particles which I am trying to cast for a particular compound. The no. of particles present is of the order of 2 billion and hence the size of the text file is of the order of a few Gigabytes. The particles have been casted layer... (5 Replies)
Discussion started by: mugga
5 Replies

7. Shell Programming and Scripting

awk append fileA.txt to growing file B.txt

This is appending a column. My question is fairly simple. I have a program generating data in a form like so: 1 20 2 22 3 23 4 12 5 43 For ever iteration I'm generating this data. I have the basic idea with cut -f 2 fileA.txt | paste -d >> FileB.txt ???? I want FileB.txt to grow, and... (4 Replies)
Discussion started by: theawknewbie
4 Replies

8. Shell Programming and Scripting

Reading txt files using the awk

Dear Shell scripters, I have a small code which copy the txt files from some destination to file name OutPutFile. I want to modify this script to introduce several constant. The string it is reading is like ... (2 Replies)
Discussion started by: nrjrasaxena
2 Replies

9. Shell Programming and Scripting

Need to append the date | abcddate.txt to the first line of my txt file

I want to add/append the info in the following format to my.txt file. 20130702|abcd20130702.txt FN|SN|DOB I tried the below script but it throws me some exceptions. <#!/bin/sh dt = date '+%y%m%d'members; echo $dt+|+members+$dt; /usr/bin/awk -f BEGIN { FS="|"; OFS="|"; } { print... (6 Replies)
Discussion started by: harik1982
6 Replies

10. Shell Programming and Scripting

Awk, sed, shell all words in INPUT.txt find in column1 of TABLE.txt and replce with column2 in

Hi dears i have text file like this: INPUT.txt 001_1_173 j nuh ]az 001_1_174 j ]esma. nuh ]/.xori . . . and have another text like this TABLE.txt j j nuh word1... (6 Replies)
Discussion started by: alii
6 Replies
PMNSMERGE(1)						      General Commands Manual						      PMNSMERGE(1)

NAME
pmnsmerge - merge multiple versions of a Performance Co-Pilot PMNS SYNOPSIS
$PCP_BINADM_DIR/pmnsmerge [-adfv] infile [...] outfile DESCRIPTION
pmnsmerge merges multiple instances of a Performance Metrics Name Space (PMNS), as used by the components of the Performance Co-Pilot (PCP). Each infile argument names a file that includes the root of a PMNS, of the form root { /* arbitrary stuff */ } The order in which the infile files are processed is determined by the presence or absence of embedded control lines of the form #define _DATESTAMP YYYYMMDD Files without a control line are processed first and in the order they appear on the command line. The other files are then processed in order of ascending _DATESTAMP. The -a option suppresses the argument re-ordering and processes all files in the order they appear on the command line. The merging proceeds by matching names in PMNS, only those new names in each PMNS are considered, and these are added after any existing metrics with the longest possible matching prefix in their names. For example, merging these two input PMNS root { root { surprise 1:1:3 mine 1:1:1 mine 1:1:1 foo foo yawn yours 1:1:2 } } foo { foo { fumble 1:2:1 mumble 1:2:3 stumble 1:2:2 stumble 1:2:2 } } yawn { sleepy 1:3:1 } Produces the resulting PMNS in out. root { mine 1:1:1 foo yours 1:1:2 surprise 1:1:3 yawn } foo { fumble 1:2:1 stumble 1:2:2 mumble 1:2:3 } yawn { sleepy 1:3:1 } To avoid accidental over-writing of PMNS files, outfile is expected to not exist when pmnsmerge starts. The -f option forces the removal of outfile (if it exists), before the check is made. The -d option allows the resultant PMNS to optionally contain duplicate PMIDs with different names in the PMNS. By default this condition is considered an error. The -v option produces one line of diagnostic output as each infile is processed. Once all of the merging has been completed, pmnsmerge will attempt to load the resultant namespace using pmLoadASCIINameSpace(3) - if this fails for any reason, outfile will still be created, but pmnsmerge will report the problem and exit with non-zero status. CAVEAT
Once the writing of the new outfile file has begun, the signals SIGINT, SIGHUP and SIGTERM will be ignored to protect the integrity of the new file. PCP ENVIRONMENT
Environment variables with the prefix PCP_ are used to parameterize the file and directory names used by PCP. On each installation, the file /etc/pcp.conf contains the local values for these variables. The $PCP_CONF variable may be used to specify an alternative configura- tion file, as described in pcp.conf(5). SEE ALSO
pmnsadd(1), pmnsdel(1), pmLoadASCIINameSpace(3), pcp.conf(5), pcp.env(5) and pmns(5). Performance Co-Pilot PCP PMNSMERGE(1)
All times are GMT -4. The time now is 04:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy