ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
I want to print contents of array that contains special characters using awk. Below is the awk code in which I am trying to print array "ARRAY" where "xx" is the index of the array.
But the code below prints ARRAY1, ARRAY2.... instead of printing the contents of array.
The contents of the array are:
ARRAY:
[\u8815S - Perce ~~~~~~~~~ ~~~~~~~~~ ~~\u573
\u8915S - add ~~~~~~~~~ ~~~~~~~~~ ~~\u583
\u8615S - sub ~~~~~~~~~ ~~~~~~~~~ ~~\u573
\u8835S - mult ~~~~~~~~~ ~~~~~~~~~ ~~\u593
\u8865S - div ~~~~~~~~~ ~~~~~~~~~ ~~\u993
.....]
The array has close to 100 elements.
Can you pls help me accessing the special character array within awk?
how did you initialize that array? here you can find some practical example
_____________________________________
If someone helps you, or you approve of what's posted, click the "Add to Reputation" button, on the left of the post.
Happy with solution ... mark as SOLVED
(located in the "thread tools")
That is fine, can you post the code? And please do not forget to use [code][/code] to keep formatting. Have you checked the examples?
_____________________________________
If someone helps you, or you approve of what's posted, click the "Add to Reputation" button, on the left of the post.
Happy with solution ... mark as SOLVED
(located in the "thread tools")
Above is the code I used to copy the contents of file into array.
I basically want each line of the file to be added below the line in which the match is found. And enclose the line between "<Name xml:lang=\"sp\"> and </Name> only if the pattern matched line contains ns:translate.
Sorry, I think is is not awk but bash. You will not be able to handle that array in awk. I do not really understand what you need, but probably something like this:
_____________________________________
If someone helps you, or you approve of what's posted, click the "Add to Reputation" button, on the left of the post.
Happy with solution ... mark as SOLVED
(located in the "thread tools")
Now I need to check for the patterns .*ns1:translate="yes">(.*)</.*
and when found I need to add string from the array below this line.
Along with the string from the array I need to add the tags <Name
xml:lang="ja"> and </Name> around the string obt from the array if the
line above has </Name> and need to add <Title xml:lang="ja"> and
</Title> tags if the pattern matched line has </Title>
where the strings "\u886815wEM - perce ~~~~~~~~~ ~~~~~~~~~ ~~\u5834" etc ... are there in an array. I have read contents of file into array.
Any idea how to script this? I tried with sed inside a while loop that reads file line by line but it takes a very long time. I tried with awk but I am not able to access the special character array inside awk
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.