The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
file searching... Kaminski Shell Programming and Scripting 1 02-02-2008 07:23 AM
which is best searching option dbsurf Shell Programming and Scripting 3 01-27-2008 08:33 PM
Searching in VI andyblaylock UNIX for Dummies Questions & Answers 1 11-28-2007 08:32 PM
searching searching tony3101 Shell Programming and Scripting 3 06-04-2004 12:50 PM
directory searching st00pid_llama Shell Programming and Scripting 2 05-10-2004 08:21 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-02-2003
yotoruja yotoruja is offline
Registered User
  
 

Join Date: Oct 2003
Posts: 5
searching for {

Hello,


I am having a hard time trying to do the following:

I have a file that looks like this:

0 CacheMaxConn 4 64
0 RMThread 16 3423423
7 DataSource 0 /hello/sas/ses
0 {94545B4-E343-1410-81E4-08000000} 3 DDBE
3 Source 9 dfskf

if the second part of the line in the text file starts with "{" I want to ignore it.

any help would be appreciated
  #2 (permalink)  
Old 11-02-2003
Simerian Simerian is offline
Registered User
  
 

Join Date: Oct 2003
Location: United Kingdom
Posts: 37
By "2nd part part of the line", I assume you mean the 2nd field. As you process each record and the relevant fields, the real issue is the construction of a suitable selection that determines whether the first character is a "{".

Personally, I would want to check for a data value that is surrounded by "{" and "}" if that is the definitive trigger for data that needs to be ignored (as in the example you provided).

Assuming the 2nd field is in a variable named ${F2} and using the ksh:

if [[ ${F2} = {*} ]] then

may work (I haven't tried it...)

Alternatively, for more complex comparisons, you may want to try regular expression through egrep and check the return code.
  #3 (permalink)  
Old 11-02-2003
oombera's Avatar
oombera oombera is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2002
Location: Cleveland, OH
Posts: 804
Building on what Simerian said, you could possibly use this code to weed out unwanted lines:
Code:
awk '{print $2}' aFile | while read LINE; do
 if [[ $LINE != {*} ]]; then
  echo $LINE
 fi
done
  #4 (permalink)  
Old 11-02-2003
yotoruja yotoruja is offline
Registered User
  
 

Join Date: Oct 2003
Posts: 5
Thanks guys. This was very helpful.
  #5 (permalink)  
Old 11-03-2003
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,409
You could use awk to remove the lines where the second field begins with {
Code:
awk '$2!~"^\{"' file1 > file2
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:36 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0