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.
details.txt
USSD WAS CB3-WAS-APP
Virtu CB-Pro CB4-CB-Pro-APP
Virtu CB-Pro CB4-CB-Pro-Catal
BI CCAPZP01 CB4-CCAPZP01-APP
BI CCAPZP02 CB4-CCAPZP02-APP
grep -Ei '$x[[:space:]]+$y' I am using it as there is tab in between in details file. I am not getting desired output, meaning for the 1st line it does take x as was but doesn't give me USSD from details file instead it displays $x. But when I execute manually it does give me USSD. What am i doing wrong
was CB3-WAS-APP
CB-Pro CB4-CB-Pro-APP
CB-Pro CB4-CB-Pro-Catal
CCAPZP01 CB4-CCAPZP01-APP
CCAPZP02 CB4-CCAPZP02-APP
Expected output should be, which is same as details.txt, However i need to do it through while loop as I need to display many other things other than just these 3 details each line
USSD WAS CB3-WAS-APP
Virtu CB-Pro CB4-CB-Pro-APP
Virtu CB-Pro CB4-CB-Pro-Catal
BI CCAPZP01 CB4-CCAPZP01-APP
BI CCAPZP02 CB4-CCAPZP02-APP
It will help to wrap the script in [code[ [/code] tags.
About the question, but not looking at the rest of the script, one way to read multiple variables to use additional file descriptors and read two files:
Code:
while read -u3 x; read -u4 y;
do
echo $x $y;
done 3< file1.txt 4< file2.txt
Mind the spacing with the redirects, there can't be any space between the file descriptor number and the redirection symbol.
It will be up to you to ensure that the two files contain the exact same number of lines.
I believe there is something wrong in my grep, when I use variables it doesn't give me anything However when I use exact text it does work.
Yes, there are several things amiss there. However, one of them is the use of single quotes ' where double quotes " should be used. The latter allow for interpretation of shell variables, the former do not. Again, see the comments about cat and co.
What do you need to add to it or change so that it will do the job? From here it looks like it illustrates two ways of using awk to combine several activities into one.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.