Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
This is a Fix message - it is a type of protocol for transmitting financial data
each number followed by a = sign is a tag - each tag means something.
some tage are moe important than other.
However, I need something that will take out multipe tags all at once ( instaed of hitting each line with the one liner and then cutting and pasting the values to an excel speadsheet).
I need something like this - something that takes out the same tags from each line:
35=D 43=N 56=Broker 54=1
35=F 43=N 56=Broker 54=1
the first three tags of fix messages are always in the same order - but the rest arr not. Sed and awk will not work, because it goes by column, I need something that will go after the characters itself.
perl -nle 'print if /regex/' works great - for one regex at a time.
I guess I will try making a while loop - that reads in the whole line and splits out the regex one by one.
An array to hold all of your matching back references
A more sophisticated regular expression which will capture all of the fields that you want to capture.
In this case, I'm using the regular expression alternation operator '|' to specify which fields to pull, and then I'm loading all of the matching backreferences into the array '@matches'
yeah that is a nice script - look at what i came up with (don't laugh)
while read line
do
echo $line | perl -nle 'print /(35=[A-Z0-9]{1,2})/'
echo $line | perl -nle 'print /(39=[A-Z0-9]{1,2})/'
sleep 3
printf "this line is over\n"
done < fixmessage3
35=8
39=E
this line is over
35=D
this line is over
35=F
this line is over
i was going to post this and ask the forum
for a way to print the values on one line - like this:
35=8 39=E
this line is over
35=D
this line is over
35=F
this line is over
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.