Here's my problem: I'm putting some interface information to a file:
then for each unique IP in this file, I'm gathering some information, so I do this:
for 99% of my script it works fine, but using the example above, I get this:
How is it that this first line is matching? It just makes no sense. I'm in ksh btw.
I appreciate any help that anyone can offer
Turk
Last edited by methyl; 02-16-2012 at 05:50 PM..
Reason: please use code tags
This is because the dot is interpreted instead of being taken as litteral
To ensur the dot is taken as litteral, you must escape it by adding a backslash before it (or more if one is not sufficient)
give a try to this :
If you are trying to match a literal string, save yourself the hassle of escaping metacharacters and don't use regular expressions at all. See grep's -F option.
Thanks all,
I'm finding it difficult to escape the "." as I'm assigning the IP address to a variable. I guess it is possible to cut up the IP address and do it that way...
I did try the -F parameter, and got some interesting results. In the example above, it worked correctly , and only returned the desired IP address, but on others in the list, I got results where multiple lines were returned, but those were typically when I have .2 and a .22 or something along those lines, where the found string is correct, but part of a larger string, that i don't want.
What I found interesting is that out of close to 7000 IP addresses, only the example above was parsed incorrectly.
Your data as posted has a leading space character before the IP Address and at least one trailing space character after the IP Address.
You could include the space characters in the string.
This technique works best with "grep -F" because there is no chance of some weird pattern match.
Hi,
inp is like below,
if we want to grep the second one, we have to use the below code,
just add the space at the end of ip variable.
Cheers,
Ranga:-)
I did try the -F parameter, and got some interesting results. In the example above, it worked correctly , and only returned the desired IP address, but on others in the list, I got results where multiple lines were returned, but those were typically when I have .2 and a .22 or something along those lines, where the found string is correct, but part of a larger string, that i don't want.
See also the -x option.
I'm sure we could give you much better advice in less time than its taken so far if we had a better description of the bigger picture, what you're trying to accomplish, along with the code to your entire script and the environment in which it runs. For all we know, you may not even be using the best tool for the job.
Hello, :)
I've an issue with the creation of a directory, All work without it :mad: So, below, my scripts with the debug output :
#!/bin/bash
# PATHS
HOME_BACKUP="/home/backup"
HOME_SCRIPT="/home/scripts/test/backup_server"
TARGET="/var/www"
# DATE
DATE_Ymd=$(date +%Y-%m-%d)
#... (1 Reply)
More issues. The "|" key doesn't work at all, either in the text terminal or in mwm (which starts fine when I do "startx").
How am I supposed to troubleshoot without a "|" key? (2 Replies)
When I use "/" to look for a particular command that I typed in the current session it says
D02:-/home/user1/temp> /job
ksh: /job: not found.
D02:-/home/user1/temp>
previously it used to fetch all the commands which had job in it..
for example subjob, endjob, joblist etc...
may I... (7 Replies)
totally pis*ed off.
I have a data set (xxx.txt), as follows:
chr1 3821 rs127372 A/C 0.823
chr1 3822 rs127376 A/C/G 0.899
chr1 3722 rs612634 A/C 9.22
chr1 3262 rs7152 A/T 0.22
chr1 3711 rs737 A/C/G 0.2323
.......
I only want to get those lines... (6 Replies)
Hi Friends,
Can any of you explain me about the below line of code?
mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`
Im not able to understand, what exactly it is doing :confused:
Any help would be useful for me.
Lokesha (4 Replies)
when i give "ps -elf" or "ps" system gets hung.
if i press "^c" come out from it...
pls help..what should i do to get it resolved.
thanks
CKanth (4 Replies)
How can I configure it?
I have a swedish keyboard with swedish keyboard setting. Everything works perfectly (едц) except that button. What can be wrong?
/Richard
++
NOTE: It seems like the computer notices the input but that the button isn't assigned to anything (the keyboard-cursor stops).... (1 Reply)
I'm using the case statement in the following script and it always takes the "*" default choice while it should be "3".
I wonder why ???
dt_auj=`date +%d`
NBLOG=`ls -al /users/notes01/LOG/t*|awk '{print $7}'|grep $dt_auj|wc -l`
case $NBLOG in
1) cat ~/LOG/console-notes > $fic_tmp1 ;;
2)... (5 Replies)