ksh to find specific infomation in a delimited file
I am using ksh and looking for a simple way to print the entire row when a specific column contains specific infomation. I know I can use grep to find the information however I can not specify the column.
I would like to list only all of the lines where the 3rd delimted filed contains the number 223:
You can use "grep" without problems, you just have to construe your regexp accordingly:
searches for "line start, followed by any number of non-',' followed by a ',' (=field1), followed by any number of non-',' followed by a ',' (=field2), followed by '223,' (=field3).
You can use "grep" without problems, you just have to construe your regexp accordingly:
searches for "line start, followed by any number of non-',' followed by a ',' (=field1), followed by any number of non-',' followed by a ',' (=field2), followed by '223,' (=field3).
I hope this helps.
bakunin
bakunin, that works great! I never knew you could do that with grep. Any ideas how I could pull out infomation with both 223 or 224 or maybe another number? maybe like an egrep "'^[^,]*,[^,]*,223,'|'^[^,]*,[^,]*,224'"?
This is true but in fact it is even easier, when values are adjacent. You won't even need extended regexps for this:
search for '...' followed by "22", followed by either a "3" or a "4".
Such "character ranges" can do many things, here are a few examples:
"[a-z]" search for a single lowercase character
"[0-9]" search for a single digit number
"[0-9]*[02468]" search for an even number
"+*[0-9][0-9]*[^.]*" search for a positive integer (an optional plus-sign, followed by a non-zero number of numeric digits, followed by anything except a comma)
Hi All,
we have a requirement to split a content in a text file every 5 rows and write in a new file .
conditions:
if 5th line falls between center of the statement . it should look upto after ";"
files are below format:
1 UPDATE TABLE TEST1 SET VALUE ='AFDASDFAS'
2 WHERE... (3 Replies)
Hi Experts,
I have a tab deliminated file as below
myfile.txt
Local Group Memberships *Administrators *Guests
I need data in below format starting from 4th position.
myfile1.txt
Administrators Guests
the above one is just an example and there could... (15 Replies)
Hi All, I will need an help with respect to replacing a range of columns on a non-delimited file using a particular string pattern.
Say file input is
MYNUMBERD000000-BAN CHUE INSNTS ** N+
MYAREDSDD000000+BAN CHUE INSNTS ** N+
MYDERFFFSD00000-GIR PENT - ACH ** ... (5 Replies)
i have a '|' delimited file having 4 fields.
now i want to sort the data by combination of first three fields without changing order of 4th field.
input file looks like this:
3245|G|kop|45
1329|A|uty|76
9878|K|wer|12
3245|G|kop|15
1329|A|uty|56
9878|K|wer|2
3245|G|kop|105... (4 Replies)
Hi friends,
I have a file where I should search for a string and get the rest of the line but without the delimiter using awk.
for example I have the series of string in a file:
input_string.txt
bbb
ccc
aaa
and the mapping file looks like this.
mapping.txt
aaa|12
bbb|23
ccc|43... (11 Replies)
I have a space delimited text file with two columns. I would like to add NA to the first column of the text file.
Input:
19625 10.4791768259
19700 10.8146489183
19701 10.9084026759
19702 10.9861346978
19703 10.9304364984
Output:
NA19625 10.4791768259
NA19700 10.8146489183... (1 Reply)
this is Korn shell unix.
The scenario is I have a pipe delimited text file which needs to be customized. say for example,I have a pipe delimited text file with 15 columns(| delimited) and 200 rows. currently the 11th and 12th column has null values for all the records(there are other null columns... (4 Replies)
I have a space delimited text file with 1,000,000+ columns? I would only like to view specific ones (let's say through 1:10), how can I do that? Thanks! (3 Replies)
I have this space delimited large text file with more than 1,000,000+ columns and about 100 rows. I want to delete all the cells that consist of just 2 (leave 2's that are not by themselves intact):
File before modification
aa bb cc 2 NA100 dd
aa b1 c2 2 NA102 de
File after modification... (1 Reply)