Sponsored Content
Full Discussion: grep for a particular field
Top Forums Shell Programming and Scripting grep for a particular field Post 302534947 by dbashyam on Wednesday 29th of June 2011 08:12:53 AM
Old 06-29-2011
grep for a particular field

Hi All,

I have the following in a text file

Code:
#---- Set Silent License Acceptance
#---- Accept license agreement: remove # sign
#----                 example: LICENSE_ACCEPTED=true
#---- if the LICENSE_ACCEPTED is anything other then true the installation will exit
#----        no log will be produced, no indication of failure provided
#----
#---- By removing the # sign before #LICENSE_ACCEPTED=false and changing false to true
#---- you have signified acceptance of the Netcool/Impact 5.1.1 license agreement
#LICENSE_ACCEPTED=false

I want to grep only the LICENSE_ACCEPTED=false alone. The LICENSE_ACCEPTED=false is present at the bottom I don't want to grep anything in the middle and this LICENSE_ACCEPTED=false has a '#' symbol also. So, how to grep this part alone

I am actually grepping this field and making false to true by using the following command but the current command greps all the LICENSE_ACCEPTED

Code:
echo "`grep -q LICENSE_ACCEPTED $NCHOME/installSilent_response.txt && sed 's#LICENSE_ACCEPTED=[^ ]*#LICENSE_ACCEPTED='${RESPONSE}#g'' $NCHOME/installSilent_response.txt || sed '$ a LICENSE_ACCEPTED='${RESPONSE}' $NCHOME/installSilent_response.txt'`" >> $NCHOME/installSilent_response_hp.txt

So,

1. how to remove the # from the legal unique LICENSE_ACCEPTED
2. And then just grep the unique LICENSE_ACCEPTED

Thanks for any help
Dinesh
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Change field separator of grep from : to space

Hi, All, I wonder how to change the field separator of grep from : to space when use grep to display. for example when I use grep -e 'pattern1' -e 'pattern2' -n filename to find patterns, it use : to separate patterns, but I want to use blank space. is there an option I can set to... (2 Replies)
Discussion started by: Jenny.palmy
2 Replies

2. UNIX for Dummies Questions & Answers

how to grep from specific field

the file has several date fields.for example, #2, #3,and #5 are date fields. I want grep year '2002' just within #2 field and get all the rows which content year '2002' in the #2 field. is it possible to do this? how to do it? Thanks (2 Replies)
Discussion started by: tiff-matt
2 Replies

3. Shell Programming and Scripting

Help with grep at specific field of a file

hi, I would like to search for a specific string at a specific line in a file and would like to know the count of it. eg: samp.txt ABC 1234 BELL HNZ 4567 RING NNN 5673 BELL Please help with the command to find the count of BELL in the above file samp.txt at the specific line 10 with... (7 Replies)
Discussion started by: techmoris
7 Replies

4. UNIX for Dummies Questions & Answers

unable to grep the reqd field

hi all, i have a data sm thg like this 28504 0 abc 148782859 42 101M nhmmmm ilopo abc 2345432 i want to get only the field which is just aftr abc i,e., 148782859, 2345432 i have used grep /abc\t/ filename to get that but its not working can any 1 help me out (5 Replies)
Discussion started by: anurupa777
5 Replies

5. UNIX for Dummies Questions & Answers

grep lines in a file that have only one field

Hello. How does one grep lines in a file that have only one field? AAA BBB CCC DDD AAA CCC Is is possible to grep "DDD" becuase it has only one field? Thanks. ---------- Post updated at 08:03 PM ---------- Previous update was at 07:25 PM ---------- I found it, thank you! awk 'NF... (2 Replies)
Discussion started by: jimmyf
2 Replies

6. Shell Programming and Scripting

How to grep a single field from a line?

hi, i have a text file with some fields. file.txt aaa|bbb|ccc|1-sh|2-sh|5-sh ddd|eee|fff|1-sh|4-sh i am selecting a line using grep command using the combination of 1st 3 column. grep "aaa|bbb|ccc" file.txt output: aaa|bbb|ccc|1-sh|2-sh|5-sh now i want to cut a field from this... (5 Replies)
Discussion started by: Little
5 Replies

7. UNIX for Dummies Questions & Answers

Grep based on first field

I want to grep based on first column and print all the columns. for eg. root 12344 /sh root 33389 /bash oracle 87378 /tech/oracle oracle 26367 /tmp/oracle Now I want to grep based on user "root" in first column and print like below. root ... (14 Replies)
Discussion started by: baladelaware73
14 Replies

8. Shell Programming and Scripting

Match and Grep the nearest value in last field

Gents I have this input file file1 (uniq records) 54503207851 170211240 54503207911 170210837 54503208111 170215105 54503208112 170215210 54655210011 170223140 54655210091 170223738 54655210172 170224355 54655210251 170224741 54655210331 170225039 54655210411 170225505 54655210492... (13 Replies)
Discussion started by: jiam912
13 Replies

9. UNIX for Beginners Questions & Answers

How to grep/awk only particular field?

I have a file like this. I want to filter values for only the particular day. Source file: # cat /tmp/1 Name Mon Tue Wed Thu Fri Sat Sun A Y B Y C Y D Y F Y G Y Y # For ex: I want to... (4 Replies)
Discussion started by: thomasraj87
4 Replies

10. UNIX for Beginners Questions & Answers

Using grep for a particular field

Hi , I have a file as shown below : 1836 21000 01052019 BH90P.TEMP.DA1836.FTP W NULL S 1836 22000 01052019 BH90P.TEMP.DA1836.FTP W 1836/21000 ... (2 Replies)
Discussion started by: krishnaswarnkar
2 Replies
ppmtosixel(1)						      General Commands Manual						     ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 04:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy