Sponsored Content
Top Forums Shell Programming and Scripting Extract value from delimited file base on white list Post 302441577 by milo7 on Sunday 1st of August 2010 10:03:23 AM
Old 08-01-2010
Extract value from delimited file base on white list

I would like to use a variable to store the IDs that I would like to extract.

I would like to extract a list of values of the IDs from a delimited string. Using bash here.

file format would be
Code:
id1=we1;id2=er2;id3=rt3;id4=yu4

The number of fields and records is not fixed. There could be just one id stored, or it could go on and on. Each record is separated by a new line and Each record starts with some random redundant text that I am not interested in..
Code:
~redundant text not interested in ~
id1=1;id2=2;id3=4;
.................;id80=8

~redundant text not interested in ~
id1=1; ................;id9=11

I am trying out the code below
Code:
list="id1,id2" #extract only id1 and id2, can be changed. each id is delimited by ','

#loop the list and extract the values of the id out
for i in $list
...
#store the value (eg 1 for id1) so that I can do a comparison 
#

if the id is less than/equal 10 i would like to print the value
if the id value is more than 10.. i would like to print the id name out as well. eg (id9=11)

How do I approach this problem? Thank you.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to extract a tilde delimited file in unix

i have a file in unix in which datas are like this 07 01 abc data entry Z3 data entry ASSISTANT Z3 39 08 01 POD peadiatrist Z4 POD PeDIATRY Z4 67 01 operator specialist 00 operator UNSPECIFIED A0 00 ... (12 Replies)
Discussion started by: trichyselva
12 Replies

2. UNIX for Dummies Questions & Answers

Extract records by column value - file non-delimited

the data in my file is has no delimiters. it looks like this: H52082320024740010PH333200612290000930 0.0020080131 D5208232002474000120070306200703060580T1502 TT 1.00 H52082320029180003PH333200702150001 30 100.0020080205 D5208232002918000120070726200707260580T1502 ... (3 Replies)
Discussion started by: jclanc8
3 Replies

3. Shell Programming and Scripting

Extract lines between 2 strings add white space

I'm trying to extract all the lines between 2 strings (including the lines containing the strings) To make the strings unique I need to include white space if possible. I'm not certain how to do that. sed -n '/ string1 /,/string2/p' infile > outfile & (4 Replies)
Discussion started by: dcfargo
4 Replies

4. Shell Programming and Scripting

Separating delimited file by pattern with exclusion list

I have a file with the contents below jan_t=jan;feb_t=feb;mar_t=mar;year=2010 jan_t=null;feb_t=feb;mar_t=mar;year=2010 jan_t=jan;feb_t=feb;mar_t=mar;year=2010 I want to extract out all the fields values ending with "_t" , however, i want to exclude feb_t and mar_t from the results In... (6 Replies)
Discussion started by: alienated
6 Replies

5. Shell Programming and Scripting

bash extract all occurences delimited from <name> and </name> tags from an xml file

I need to extract all text delimited from <name> and </name> tags from an xml file, but not only first occurence. I need to extract all occurences. I've tried with this command: awk -F"<name>|</name>" 'NF>2{print $2}' but it give only first occurence. How can i modify it? (18 Replies)
Discussion started by: ingalex
18 Replies

6. Shell Programming and Scripting

Extract second column tab delimited file

I have a file which looks like this: 73450 articles and news developmental psychology 2006-03-30 16:22:40 1 http://www.usnews.com 73450 articles and news developmental psychology 2006-03-30 16:22:40 2 http://www.apa.org 73450 articles and news developmental psychology 2006-03-30... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

7. Shell Programming and Scripting

Extract a nth field from a comma delimited file

Hi, In my file (which is "," delimited and text qualifier is "), I have to extract a particualr field. file1: 1,"aa,b",4 expected is the 2nd field: aa,b I tried the basic cut -d "," -f 2 file 1, this gave me aa alone instead aa,b. A small hint ot help on this will be very... (5 Replies)
Discussion started by: machomaddy
5 Replies

8. Shell Programming and Scripting

Oracle table extract: all columns are not converting into pipe delimited in flat file

Hi All, I am writing a shell script to extract oracle table into a pipe dilemited flat file. Below is my code and I have attached two files that I have abled to generate so far. 1. Table.txt ==> database extract file 2. flat.txt ==> pipe delimited after some manipulation of the original db... (5 Replies)
Discussion started by: express14
5 Replies

9. Shell Programming and Scripting

List and Delete Files which are older than 7 days, but have white spaces in file name

I need to list and delete all files in current older which are olderthan 7 days. But my file names have white spaces. Before deleting I want to list all the files, so that I can verify.find . -type f -mtime +7 | xargs ls -l {} But the ls command is the working on the files which have white... (16 Replies)
Discussion started by: karumudi7
16 Replies

10. Shell Programming and Scripting

Split a content in a file with specific interval base on the delimited values using UNIX command

Hi All, we have a requirement to split a content in a text file every 5 rows and write in a new file . conditions: if 5th line falls between center of the statement . it should look upto after ";" files are below format: 1 UPDATE TABLE TEST1 SET VALUE ='AFDASDFAS' 2 WHERE... (3 Replies)
Discussion started by: KK230689
3 Replies
xgettext(1)						      General Commands Manual						       xgettext(1)

NAME
xgettext - conditionally extract strings from C programs SYNOPSIS
xgettext -d [ cmnopvhP ] [ -odirectory-prefix ] [ -xexclude-list ] [ filename ... ] xgettext [ -amopvhP ] [ -xexclude-list ] [ filename ... ] DESCRIPTION
xgettext is used to automate the creation of portable message files. A portable message file contains copies of "C" strings that are found in "C" source code in filename. When the -d option is specified, xgettext places the extracted strings in the file name.po. name is either the domain specified in a dgettext call, or messages.po for strings extracted from gettext and textdomain calls. If the -d flag is not specified, xgettext places all the strings in messages.po. The portable message file can be used as input to the msgfmt(1) utility, which will produce a binary form of the message file than can be used at application run-time. OPTIONS
-a Extract ALL strings, not just those found in gettext, dgettext, and textdomain calls. -cflag Comments beginning with flag filename on the first line of the comment are added to file filename as # delimited comments. -d Produce duplicates. Does not sort output when writing the portable message file and will not overwrite existing output files. Places output from each domain specified in a dgettext call into a separate file named for the domain, ie. name.po -cflag Comments beginning with flag filename on the first line of the comment are added to file filename as # delimited comments. -mstring Causes xgettext to fill in the msgstr line of the portable message files it produces. xgettext uses the corresponding msgid string extracted from the "C" file, appending string. Useful for debugging purposes. -n Add # delimited line number comments to output file indicating the line number in the source file where each extracted string is encountered. -ofilename rename the default output file from messages.po to filename. -ppathname Specify the directory where the output files will be placed. This option overrides the current working directory. -xfilename Specify a file that contains a list of strings that are not be extracted from the input files. Each string to be excluded must appear on a line by itself in the file filename. -P include strings in pre-processor statements. -v Verbose mode. -h Print a help message on standard output. FILES
messages.po is always created, but may be empty. SEE ALSO
msgfmt(1), xstr(1), gettext, dgettext, textdomain(3). 14 Sep 1990 xgettext(1)
All times are GMT -4. The time now is 05:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy