![]() |
Comparing to specific line in file bash script
Hi,
I have a value stored in x and I need to compare it to the numbers in every other line of a file. The file contains alternating lines of numbers and letters: aaaa1111 AAAAAAAA bbbb2222 BBBBBBBB cccc3333 CCCCCCCC I need to compare x to the numbers in every other line without the first four characters of that line. So I want to compare x to 1111, then to 2222, then 3333. This is to be the condition in an if statement: if [ $x = (line 1 without first four characters) ] or if [ $x = (line 3 without first four characters) ] I know I would have to use something along the lines of = $(sed something) or maybe cut, but I don't know how to reference the file by line. Let me know if I need to be more clear. Thanks for any help! |
Quote:
If you show you've put some effort into things, and tell us where you're stuck, you're much more likely to get a favorable response. |
Quote:
Code:
#print lines by number (3 thru 8):http://www.grymoire.com/Unix/Sed.html |
another good trick here---found by Google using "sed print line)
http://www.linuxforums.org/forum/pro...using-sed.html |
| All times are GMT -5. The time now is 04:48 AM. |