Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Shell - Read a text file with two words and extract data Post 302983628 by Scrutinizer on Friday 14th of October 2016 04:23:25 AM
Old 10-14-2016
You're welcome,

-a means read into an array (when using bash). F is the name of the array

printf is the preferred and standardized alternative to echo. The first field to printf is the "format string" . "%s" means "string" and "\n" means new line". See: printf or the bash man page.

To get all the element of the array one normally uses: "${F[@]}"
"${F[@]# }" does the same, but in addition it uses parameter expansion and # means cut off a leading space if it exists.

Since F is an array it will work on every element of the array (more about this in the bash man page).

With the while read loop, for every line of the input file, the array F gets filled anew.

Last edited by Scrutinizer; 10-14-2016 at 05:34 AM..
This User Gave Thanks to Scrutinizer For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to read all the unique words in a text file

How can i read all the unique words in a file, i used - cat comment_file.txt | /usr/xpg6/bin/tr -sc 'A-Za-z' '/012' and cat comment_file.txt | /usr/xpg6/bin/tr -sdc 'A-Za-z' '/012' but they didnt worked..... (5 Replies)
Discussion started by: aditya.ece1985
5 Replies

2. Shell Programming and Scripting

To read and separate number and words in file and store to two new file using shell

hi, I am a begginer in unix and i want to know how to open a file and read it and separate the numbers & words and storing it in separate files, Using shell scripting. Please help me out for this. Regards S.Kamakshi (2 Replies)
Discussion started by: kamakshi s
2 Replies

3. Shell Programming and Scripting

shell script to read data from text file and to load it into a table in TOAD

Hi....can you guys help me out in this script?? Below is a portion text file and it contains these: GEF001 000093625 MKL002510 000001 000000 000000 000000 000000 000000 000001 GEF001 000093625 MKL003604 000001 000000 000000 000000 000000 000000 000001 GEF001 000093625 MKL005675 000001... (1 Reply)
Discussion started by: pallavishetty
1 Replies

4. Shell Programming and Scripting

Shell script to read lines in a text file and filter user data

hi all, I have this file with some user data. example: $cat myfile.txt FName|LName|Gender|Company|Branch|Bday|Salary|Age aaaa|bbbb|male|cccc|dddd|19900814|15000|20| eeee|asdg|male|gggg|ksgu|19911216||| aara|bdbm|male|kkkk|acke|19931018||23| asad|kfjg|male|kkkc|gkgg|19921213|14000|24|... (4 Replies)
Discussion started by: srimal
4 Replies

5. Shell Programming and Scripting

How to read the data from the text file in shell script?

I am having one text file and i need to read that data from my shell script. I will expain you the scenario: Script look like: For name type 1: For age type 2: For Salary type3: echo "Enter the input:" read the data if input is 1 then go to the Text file and print the... (2 Replies)
Discussion started by: dineshmurs
2 Replies

6. Shell Programming and Scripting

Script to read file and extract data by matching pattern

Hello, I have a file ( say file1) which has lines like below. xxxx:xxxx,yyyy,1234,efgh zzzz:zzzz,kkkk,pppp,1234,xxxx,uuuu,oooo dddd:dddd here the word before ":" ( ie: xxxx) is the file name and the string after : are also file names, but each file name separated by "," In case of... (20 Replies)
Discussion started by: pradeepmacha
20 Replies

7. Shell Programming and Scripting

regular expression with shell script to extract data out of a text file

hi i am trying to extract some specific data out of a text file using regular expressions with shell script that is using a multiline grep .. and the tool i am using is pcregrep so that i can get compatibility with perl's regular expressions for a sample data like this, i am trying to grab... (6 Replies)
Discussion started by: vemkiran
6 Replies

8. Shell Programming and Scripting

I need to extract uique words from text file

Hello programmers, I need to create a list of unique words from a text file using PERL...may i have the code for that please? Thank you (1 Reply)
Discussion started by: alsohari
1 Replies

9. UNIX for Dummies Questions & Answers

Shell script to read lines in a text file and filter user data Shell Programming and Scripting

sxsaaas (3 Replies)
Discussion started by: VikrantD
3 Replies

10. Shell Programming and Scripting

Read csv file, convert the data and make one text file in UNIX shell scripting

I have input data looks like this which is a part of a csv file 7,1265,76548,"0102:04" 8,1266,76545,"0112:04" I need to make the output data should look like this and the output data will be part of text file: 7|1265000 |7654899 |A| 8|12660000 |76545999 |B| The logic behind the... (6 Replies)
Discussion started by: RJG
6 Replies
GLIB-MKENUMS(1) 						  [FIXME: manual]						   GLIB-MKENUMS(1)

NAME
glib-mkenums - C language enum description generation utility SYNOPSIS
glib-mkenums [options...] [files...] DESCRIPTION
glib-mkenums is a small perl-script utility that parses C code to extract enum definitions and produces enum descriptions based on text templates specified by the user. Most frequently this script is used to produce C code that contains enum values as strings so programs can provide value name strings for introspection. INVOCATION
glib-mkenums takes a list of valid C code files as input. The options specified control the text that is output, certain substitutions are performed on the text templates for keywords enclosed in @ characters. Options --fhead text Put out text prior to processing input files. --fprod text Put out text everytime a new input file is being processed. --ftail text Put out text after all input files have been processed. --eprod text Put out text everytime an enum is encountered in the input files. --vhead text Put out text before iterating over the set of values of an enum. --vprod text Put out text for every value of an enum. --vtail text Put out text after iterating over all values of an enum. --comments text Template for auto-generated comments, the default (for C code generations) is "/* @comment@ */". --template file Read templates from the given file. The templates are enclosed in specially-formatted C comments /*** BEGIN section ***/ /*** END section ***/ where section may be file-header, file-production, file-tail, enumeration-production, value-header, value-production, value-tail or comment. --help Print brief help and exit. --version Print version and exit. Production text substitutions Certain keywords enclosed in @ characters will be substituted in the emitted text. For the substitution examples of the keywords below, the following example enum definition is assumed: typedef enum { PREFIX_THE_XVALUE = 1 << 3, PREFIX_ANOTHER_VALUE = 1 << 4 } PrefixTheXEnum; @EnumName@ The name of the enum currently being processed, enum names are assumed to be properly namespaced and to use mixed capitalization to separate words (e.g. PrefixTheXEnum). @enum_name@ The enum name with words lowercase and word-separated by underscores (e.g. prefix_the_xenum). @ENUMNAME@ The enum name with words uppercase and word-separated by underscores (e.g. PREFIX_THE_XENUM). @ENUMSHORT@ The enum name with words uppercase and word-separated by underscores, prefix stripped (e.g. THE_XENUM). @VALUENAME@ The enum value name currently being processed with words uppercase and word-separated by underscores, this is the assumed literal notation of enum values in the C sources (e.g. PREFIX_THE_XVALUE). @valuenick@ A nick name for the enum value currently being processed, this is usually generated by stripping common prefix words of all the enum values of the current enum, the words are lowercase and underscores are substituted by a minus (e.g. the-xvalue). @type@ This is substituted either by "enum" or "flags", depending on whether the enum value definitions contained bit-shift operators or not (e.g. flags). @Type@ The same as @type@ with the first letter capitalized (e.g. Flags). @TYPE@ The same as @type@ with all letters uppercased (e.g. FLAGS). @filename@ The name of the input file currently being processed (e.g. foo.h). @basename@ The base name of the input file currently being processed (e.g. foo.h). (Since: 2.22) Trigraph extensions Some C comments are treated specially in the parsed enum definitions, such comments start out with the trigraph sequence /*< and end with the trigraph sequence >*/. Per enum definition, the options "skip" and "flags" can be specified, to indicate this enum definition to be skipped, or for it to be treated as a flags definition, or to specify the common prefix to be stripped from all values to generate value nicknames, respectively. The "lowercase_name" option can be used to specify the word separation used in the *_get_type() function. For instance, /*< lowercase_name=gnome_vfs_uri_hide_options >*/. Per value definition, the options "skip" and "nick" are supported. The former causes the value to be skipped, and the latter can be used to specify the otherwise auto-generated nickname. Examples: typedef enum /*< skip >*/ { PREFIX_FOO } PrefixThisEnumWillBeSkipped; typedef enum /*< flags,prefix=PREFIX >*/ { PREFIX_THE_ZEROTH_VALUE, /*< skip >*/ PREFIX_THE_FIRST_VALUE, PREFIX_THE_SECOND_VALUE, PREFIX_THE_THIRD_VALUE, /*< nick=the-last-value >*/ } PrefixTheFlagsEnum; SEE ALSO
glib-genmarshal(1) [FIXME: source] 05/02/2010 GLIB-MKENUMS(1)
All times are GMT -4. The time now is 06:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy