10-16-2008
extract lines based on few conditions
Hi,
I need to extract lines based on some conditions as explained below:
File format details:
notes:
1. each set starts with AAA only
2. number of columns is fixed
3. number of rows per set may vary (as one set is upto DDD - 4 rows)
Now, if any BBB's 5th column is blank then then script should provide us it's AAA line.
For. e.g, i have data for 3 sets and file has the below:
AAA,1,a,b,c,d
CCC,1,p,q,r,s
BBB,1,j,k,l,m
AAA,2,j,k,l,m
BBB,2,a,b,c,d
AAA,3,w,x,y,z
CCC,3,p,q,r,s
DDD,3,a,b,c,d
BBB,3,j,k,,m
then the output must be
AAA,3,w,x,y,z
I could extract the line that is missing by below:
gawk -F"," '$1 == "BBB" && $5 == "" { print $0 }' /tmp/file
but clueless how to get the AAA-line of it.
Please advise.
Thanks
Prvn
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
i have a file in unix in which the records are like this
aaa 123 233
aaa 234 222
aaa 242 222
bbb 122 111
bbb 122 123
ccc 124 222
In the output i want only the below records
aaa
ccc
The validation logic is 1st column and 2nd column need to be considered
if both columns values are... (8 Replies)
Discussion started by: trichyselva
8 Replies
2. Shell Programming and Scripting
I regularly extract lines of text from files based on the presence of a particular keyword; I place the extracted lines into another text file. This takes about 2 hours to complete using the "sort" command then Kate's find & highlight facility.
I've been reading the forum & googling and can find... (4 Replies)
Discussion started by: DionDeVille
4 Replies
3. Shell Programming and Scripting
Hello Friends,
I have a file(InputFile.csv) with the following columns(the columns are pipe-delimited):
ColA|ColB|ColC|ColD|ColE|ColF
Now for this file, I have to get those records which fulfil the following condition:
If "ColB" is NOT NULL and "ColD" has values one of the following... (9 Replies)
Discussion started by: mehimadri
9 Replies
4. Shell Programming and Scripting
Hi I recently joined a project where I have been asked to generate a report using shell script accessing UNIX box.
I have no idea on how to do it as I am a beginner and learning shell scripts.
Suppose I have a XML:
Code:
... (3 Replies)
Discussion started by: vat1kor
3 Replies
5. Shell Programming and Scripting
Hi all,
I want to extract some paragraphs out of a file under certain conditions.
- The paragraph must start with 'fmri'
- The paragraph must contain the string 'restarter svc:/system/svc/restarter:default'
My input is like that :
fmri svc:/system/vxpbx:default
state_time Wed... (4 Replies)
Discussion started by: Armoric
4 Replies
6. Shell Programming and Scripting
Hi forum,
I need help .. I need to extract from the log file logfile.log all the rows between the tags "<SOAP-ENV: Envelope" "</ SOAP-ENV: Envelope>" and that contain a certain <idPrescrizione> 0FXTN091GI </ idPrescrizione>.
Within logfile.log there could be more 'occurrences of the same
... (3 Replies)
Discussion started by: mannone
3 Replies
7. UNIX for Dummies Questions & Answers
Hi Guys,
I am new to shell script.I need your help to write a shell script.
I need to write a shell script to extract data from a .csv file where columns are ',' separated.
The file has 5 columns having values say column 1,column 2.....column 5 as below along with their valuesm.... (1 Reply)
Discussion started by: Vivekit82
1 Replies
8. Shell Programming and Scripting
Gents
Can you help please.
Input file
5490921425 1 7 1310342 54909214251
5490921425 2 1 1 54909214252
5491120937 1 1 3 54911209371
5491120937 3 1 1 54911209373
5491320785 1 ... (4 Replies)
Discussion started by: jiam912
4 Replies
9. Shell Programming and Scripting
I have a folder containing text files. I need to extract specific lines from the files of this folder based on another file input.txt. How can I do this with awk/sed?
file1
ARG 81.9 8 81.9 0
LEU 27.1 9 27.1 0
PHE .0 10 .0 0
ASP 59.8 11 59.8 0
ASN 27.6 12 27.6 0
ALA .0 13 .0 0... (5 Replies)
Discussion started by: alanmathew84
5 Replies
10. UNIX for Beginners Questions & Answers
Hi All,
i would like to get some help regarding extracting certain characters from a line grepped.
blahblah{1:F01IRVTUS30XXXX0000000001}{2:I103IRVTDEF0XXXXN}{4:blah
blahblah{1:F01IRVTUS30XXXX0000000001}{2:I103IRVTDEF0XXXXN}{4:blah... (10 Replies)
Discussion started by: mad man
10 Replies
LEARN ABOUT OPENDARWIN
bestups
BESTUPS(8) NUT Manual BESTUPS(8)
NAME
bestups - Driver for Best Power / SOLA (Phoenixtec protocol) UPS equipment
NOTE
This man page only documents the hardware-specific features of the bestups driver. For information about the core driver, see nutupsdrv(8).
SUPPORTED HARDWARE
bestups was designed to monitor Best Power UPS hardware like the Fortress, Fortress Telecom, Axxium Rackmount and Patriot Pro. It also
recognizes and supports SOLA units such as the 325, 520 and 620. In addition, the Best 610 is supported using the 'ID' option.
Other UPS hardware using the Phoenixtec protocol should also work, but they will generate a warning since their battery information is not
known.
This driver does not support some older Best/SOLA units.
EXTRA ARGUMENTS
This driver supports the following optional settings in the ups.conf(5):
nombattvolt=num
Override the battery float voltage which is normally determined by asking the hardware. This is useful if your UPS constantly reports
battery.charge values just below 100% even when it's completely charged.
If you have this problem, set this to whatever battery.voltage reports when the UPS is known to be completely charged with a good
battery.
The author's Best Fortress 750 uses nombattvolt=27.4.
battvoltmult=num
Multiply the reported battery voltage by this number. Some devices report only a fraction of the total battery voltage.
For example, the SOLA 610 700VA UPS (with a 24V battery) reports the single cell voltage (about 2.27V when fully charged). In this
particular case you can set battvoltmult = 12 in ups.conf(8) to fix this.
ID=string
Set the Identification response string. This should only be used with hardware that supports the Phoenixtec protocol status inquiry
commands, but not the "ID" command, such as the Best/SOLA 610. Format of the ID string is: AAA,BBBB,CCC,DDD,EE.E,FF.F
AAA is the three-character identification for the UPS model.
BBBB is the output power in VA (volt amperes). B is an integer number ranging from 0 to 9.
CCC is the Nominal Input Voltage. C is an integer number ranging from 0 to 9. The unit is Volts AC.
DDD is the Nominal Output Voltage. D is an integer number ranging from 0 to 9. The unit is Volts AC.
EE.E is the Battery Voltage that will cause the UPS to shut itself off. E is an integer number ranging from 0 to 9. Then unit is Volts
DC and a decimal point is present.
FF.F or FFF.F is the Battery Voltage at full charge. F is an integer number ranging from 0 to 9. Then unit is Volts DC. Typically, for
700VA, 1KVA and 1.5KVA units, the format is FF.F. For 2KVA and 3KVA units, the format is FFF.F.
Example: a Best 610 1.5KVA unit would use the string "610,1500,120,120,10.0,48.0".
BUGS
The battery charge percentage value (in battery.charge) is derived from the voltage data that the UPS returns, since the UPS doesn't return
that value directly. On some hardware, the charge will remain at 100% for a long time and then drops quickly shortly before the battery
runs out. You can confirm from the battery.voltage readings that this is a problem with the UPS and not this driver.
Similarly, the float from the charger in some models forces the battery charge percentage back up to 100% immedately after the UPS goes
back on-line, so you can't tell when it is really recharged.
Finally, some models give one value for the battery's nominal voltage and yet actually have a nominal voltage slightly below that. This
leads to things such as the perpetual 98.7% charge on the author's Fortress 750, even when it's been charging for weeks. You can use
nombattvolt= in ups.conf(8) to fix this.
AUTHOR
Russell Kroll, Jason White
SEE ALSO
The core driver:
nutupsdrv(8)
Internet resources:
The NUT (Network UPS Tools) home page: http://www.networkupstools.org/
Network UPS Tools 05/21/2012 BESTUPS(8)