When a field that I am pulling with the awk command
isnt present, I would Like NA to be output in the place of the missing field.
I am completely lost here. Your sample input file contains 12 lines (with each line being a record). There is no indication given anywhere in your sample input or in the description of your requirements specifying the order in which fields are supposed to be present. Since you specify that each output record should contain NA in the place of each missing input field in each record and since none of your input records contains more than one of the six strings you're looking for in various fields, why doesn't each of the 12 output records you would get from your 12 input records contain at least 5 occurrences of NA?
I see no relationship between your description of your requirements and the desired output you say you want from your sample input.
Note that what your code seems to do is look for six strings on each input line and, if and only if, at least one of those string is found, that input record is copied to the output with NA added as the last output field on that line. All other input lines are discarded. I don't see any relationship between your code and your requirements and I don't see any relationship between your code and the desired output you say you want.
If you can't write down a clear description of your requirements, it isn't surprising that you can't write code that will do what you want. If you can't write down a clear description of your requirements, there is no chance that anyone else will be able to write code that does what you want.
I apologize, when I added the code I kept it to a minimum in an effort to keep it clearer.
This is the code used to produce the output, I see the confusion with the additional fields in the desired output. If one of the input fields is not present, I would like to insert an NA
OK. I get it. You don't want to tell us what you're trying to do. You just want us to guess at what you're trying to do by showing us code that doesn't work. Showing us more code that apparently doesn't do what you're trying to do doesn't help.
Sorry, but I can't help you under these conditions.
These 2 Users Gave Thanks to Don Cragun For This Post:
i want to search a log for a string. when that string is found, i want to grab the a set number of lines that came before the string, and a set number of lines that come after the string.
so if i search for the word "Error" in the /var/log/messages file, how can I output the 20 lines that came... (4 Replies)
hello,
I have problem with writing/adjusting a shell script.
I searched forum and unfortunately couldn't write scipt based on the information I found.
I never wtire such so it's hard for me and I do need to modify one script immediately.
case looks like:
1. 'file' that needs to be modified... (3 Replies)
Right now, my code is:
s/Secondary Ins./Secondary Ins.\
1/g
It's adding a 1 as soon as it finds Secondary Ins.
Primary Ins.: MEDICARE B DMERC Secondary Ins.
1: CONTINENTAL LIFE INS
What I really want to achieve is having a 1 added on the next line that contain "Secondary Ins." It... (4 Replies)
Hi,
I have two variables x and y.
i need to find a particular string in a file, a workflow name and then insert the values of x and y into the next lines of the workflow name.
basically it is like as below
wf_xxxxxx
$$a=
$$b=
$$c= figo
$$d=bentley
i need to grep the 'wf_xxxx' and then... (6 Replies)
Hello Everyone,
I just started scripting this week. I have no background in programming or scripting.
I'm working on a script to grep for a variable in a log file
Heres what the log file looks like. The x's are all random clutter
xxxxxxxxxxxxxxxxxxxxx START: xxxxxxxxxxxx... (7 Replies)
Hi all,
I have a question..
Here is my requirement..I have 500 files in a path say /a/b/c
I have some numbers in a file which are comma seperated...and I wanted to check if the numbers are present in the FileName in the path /a/b/c..if the number is there in the file that is fine..but if... (1 Reply)
finding a string with another string is found
EX:
abs c/-
i want to find /-, then copy abs. i know it's easy use awk, but my problem is the substr syntax.
substr($2,2,2) will give me /-
but the conflict is /- is not always the second characted of the second string. (11 Replies)
CPAN.pm: Going to build G/GA/GAAS/Unicode-String-2.09.tar.gz
Checking if your kit is complete...
Looks good
Writing Makefile for Unicode::String
cp String.pm blib/lib/Unicode/String.pm
cp lib/Unicode/CharName.pm blib/lib/Unicode/CharName.pm
/usr/bin/perl /usr/perl5/5.8.4/lib/ExtUtils/xsubpp... (5 Replies)
In my script I read a input file and search all the files in a directory and it's sub-directories for that string using:
find . -type f -print | xargs grep $var1
This just displays all the lines the string was found on. Too much data.
What I need is to store in a file one time those... (17 Replies)
Is there a way for grep to output only the found string and not the whole line?
I have a ksh script which reads in a file and loops through every line looking up on a grep -f list. For it to only display only the string found i pass this to awk as a variable and loop through the list file using... (5 Replies)