LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 03-06-2012, 03:11 AM   #16
eosbuddy
Member
 
Registered: Feb 2012
Location: India
Distribution: Ubuntu, Fedora, Gentoo, Mandrake, RedHat, CentOs
Posts: 30

Rep: Reputation: Disabled

@jack_9: the examples I've given in my previous 2 posts are for literal "\t" - particularly the sed example (you can convert the 4 spaces (before the /g) to whatever else you'd like to be in there).

Last edited by eosbuddy; 03-06-2012 at 03:12 AM.
 
Old 03-06-2012, 03:51 AM   #17
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,250

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
Yeah I am still not with you

Using your example:

If we assume that the following returns "1 2 3 4 adlkjlfd;%114 \ttow\p felk&\t*"
Code:
rec=`sed -n "$j{p;q;}" ${file}`
So when we go to the grep line why can't we:
Code:
grep -x "${rec//\\/\\\\}" ${file}_dup
 
Old 03-06-2012, 04:38 AM   #18
jack_9
LQ Newbie
 
Registered: May 2011
Posts: 23

Original Poster
Rep: Reputation: Disabled
Dunno Its not working.....



$ grep -x "${rec//\\/\\\\}" rec1
$ echo $?
1
$ echo "${rec//\\/\\\\}"
1 2 3 4 adlkjlfd;%114 \\ttow\\p felk&\\t*
$ echo $rec
1 2 3 4 adlkjlfd;%114 \ttow\p felk&\t*
$ cat rec1
1 2 3 4 adlkjlfd;%114 \ttow\p felk&\t*
$
 
Old 03-06-2012, 05:24 AM   #19
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,250

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
hmmm ... seems your -x on grep is putting you between a rock and a hard place. I think it is interpreting the \\ to be 2 slashes but when left as a single it thinks of \t
as a tab. I would add that without -x it works just fine.
 
Old 03-06-2012, 06:01 AM   #20
jack_9
LQ Newbie
 
Registered: May 2011
Posts: 23

Original Poster
Rep: Reputation: Disabled
Yeah Grail.. you are correct.. the grep(in my unix box) is really poor..
And I did not find any other option except "-x" because I need to match the entire line..

If I wont give "-x" then, the half of line will also match, which wont give me the right result or pattern matching... I think you understood my point..
 
Old 03-06-2012, 06:32 AM   #21
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,250

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
You could put start and end, ie ^$, around the string but you actually have another issue to. It appears that the current solution also has an issue that the final asterisk is not
matched unless escaped. I must say I would wonder who in their right mind would have a database filled with this gibberish??
 
Old 03-06-2012, 07:02 AM   #22
jack_9
LQ Newbie
 
Registered: May 2011
Posts: 23

Original Poster
Rep: Reputation: Disabled
Yeah, grail.. u r correct..
Finger crossed
Sybase database is also not very reliable in joins for such values(Like Space)

So, I wanted my script, should work on file level instead of database level..but in file level also I'm facing this issue..

I was happy with my Linux box and lots of options for grep and was able to do many stuffs..
However this unix box(and Sybase) is not allowing me to free up..
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
grep issue alape Linux - General 2 01-28-2012 12:49 PM
[SOLVED] tail and grep issue Wim Sturkenboom Linux - General 6 02-06-2008 08:19 AM
grep issue with SuSE 9 vm_devadas SUSE / openSUSE 6 01-24-2007 10:48 AM
Grep parsing issue selfsck Linux - General 3 07-11-2004 09:38 PM
grep -v issue lleemon Linux - General 7 06-16-2003 04:50 PM


All times are GMT -5. The time now is 01:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration