Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Hi, I am quite confused here trying to implement a scenerio in bash where I have to read a file line by line and to search that line in from another file. Basically I want to compare two files, two files as seperate inputs read each line from src_file and try to search that line in from dst_file. Case sensativity is not a problem. We can use grep -i <..> anyway, if a match is found it displays line blah = found else not found. Each line from src_file should be parsed till EOF on dst_file.
If anyone can help me out in bash, I would really appreciate.
To some extent yes, diff works but I can't parse its output. Infact I am doing this to automate some router audits for a set of commands in my SOP which may or maynot be present in the router. The I got the router current config file in here and the SOP in the other file, just want to see the commands in SOP are present in router config or not. That all.
I can do that but you see clearly it shows, for each line cat file, show the match. Means, if even a single match is from src_file, it will loop till the EOF of src_file. And the list goes on for multiple matches.
Sorry about the bumping, infact I was expecting replies a bit quicker but anyway, I'll try to follow the rules .. .. thankx
That script I gave you should do that. An example may help. Let's assume you have 2 files: src_file and dst_file.
Contents of src_file:
That script will get the first item in src_file ('orange' in this case) and compare it to every line in dst_file and display any matches. It will then move on to the second, third, etc doing the same.
What that is saying, essentially, is this:
Take each item from 'cat src_file' and store it in $line. Then, compare this to the entire contents of dst_file, line for line. Then, move onto the next line in src_file.
Logically you are correct but the script ain't doing so. I got 1 matche in both files, total 5 lines in src_file and the script is showing me the match 5 times. As you said, is should move on but its not doing so. BTW: I am prety sure the messy output does not have to do anything weather if I run it on command or script?
No, src_file does not contains any duplicate, not atleast at the moment. There are just 5 lines,
This is lane2
and this is line 5
Just like this, and dst_file contains some other different commands/lines but one or more than one from src_file for example "This is lane2". When I run the script, I get the output correct but it shows me 5 lines of the same output. Says "This is lane2"