how to extract ascii separated values in a text file?
Hi,
I have one file consisting of lines which has some info separated by "|". I want to grep the file and provides me a list of records on the 3rd, 4th entry on a single line. How will this be possible? I am guessing should be using "sed" but not an expert. Also wondering if you can provide me a good reference for logs and values manipulation. Thanks. |
Do you mean the 3rd and 4th fields on the records that get through grep?
That could be achieved with: Code:
grep <whatever> | cut -d'|' -f3,4 Code:
awk -F'|' '/pattern/ {$3, $4}' |
Given file t.t
Code:
a|b|c|d|e Code:
awk '{print $3,$4}' FS="|" t.t :) |
Thanks guys...Now another complicated thing is that inside the file, there are few texts and this information is in the middle of the line.
Example: some text some text [A|B|C|D] some text some text I want to check the pattern "II" in that line and output only those lines with that content and if possible only those starting with "[" and ending with "]". Thanks. |
I think something like
Code:
sed -e '/II/ s/.*\[\(.*\)\].*/\1/p' -n <file> |
All times are GMT -5. The time now is 11:19 PM. |