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.
It looks like your quotes are confused. You appear to have double quotes inside double quotes and single quotes inside single quotes. That's probably what's causing the "unterminated string" error. In the first example, there's a quote missing before the $1.
But I have to ask, if you want 3333 in your first example, why not
Code:
echo "123:222,234:3333"|awk -F '[:]' '{print $3}'
?? That is, change the delimiter to redefine the fields then print out the field you want.
You need to advise us on what decisions need to be made when a line from the file is read. Obviously your current solution does not work but we don't understand how you came to that code
just that it does not work.
As mentioned by syg00, there would not be any reason to call awk inside awk, you just need to use what you have correctly.
So, presented with the following input:
Code:
VAR1|11:1111,22:2222,33:3333|STD99
What decisions were made that would make the output look like:
Code:
VAR1-11:1111,22:2222,33:3333-STD99|1111
To give you an idea, from a visual point of view there are 2 steps:
1. Change the pipe (|) into a hyphen (-)
2. Using pipe, colon and comma as separators, grab the third field and place at the end after change above and put a pipe in between
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.