If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Formatting the words in a file

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-25-10, 18:24
regtha regtha is offline
Registered User
 
Join Date: Jan 2010
Posts: 72
Formatting the words in a file

I have a file named test which has content like below

abc
123
456
jshd
uieh
sjdfsdf
sjdfhjkah
jeff
jenny


I want the result as

'abc','123','456','jshd','uieh','sjdfsdf','sjdfhjk ah','jeff','jenny'

after formatting the above string

I have one logfile which has thousands of rows. From this file I have to select the lines which does not has any of the string from the file 'test'

please let me know how to do
Reply With Quote
  #2 (permalink)  
Old 01-25-10, 19:19
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
Traditionally homework is set for students to allow them to practice what they've learnt, not for students to hand it out to others to do.
Reply With Quote
  #3 (permalink)  
Old 01-25-10, 19:24
kitaman kitaman is offline
Papabi's friend
 
Join Date: Sep 2009
Location: Ontario
Posts: 626
Code:
#!/bin/ksh
LIST=; export LIST
separator=" "
while read token
do
        LIST=$LIST$separator$token
        separator=" |"
done <testfile
grep -E -v "$LIST" logfile >/exceptionlist
Damn, I see a mistake in it.

Last edited by kitaman; 01-25-10 at 19:34.
Reply With Quote
  #4 (permalink)  
Old 01-26-10, 09:59
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,455
Cool Read The Fine Manual

Quote:
Originally Posted by regtha View Post
please let me know how to do
man grep

SYNTAX
grep <options> [-f file] [file...]

OPTIONS
`-f FILE'
Obtain patterns from FILE, one per line. The empty file contains
zero patterns, and therefore matches nothing.

__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On