Sponsored Content
Top Forums Shell Programming and Scripting Shell script to read lines in a text file and filter user data Post 302363733 by Franklin52 on Wednesday 21st of October 2009 07:48:32 AM
Old 10-21-2009
Another one:

Code:
awk -F"|" '
BEGIN{h="FName|LName|Gender|Company|Branch|Bday|Salary|Age";split(h,a,"|")}
{
  s=$1" "$2" "$4" Missing Field/s: "
  for(i=1;i<NF;i++) {
    if (!$i) {s=s" "a[i];f=1}
  }
}
f{print s;f=0}' file

This is the output:

Code:
$ cat file
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|
aera|bprb|male|cccc|pppp||15000|20|
$
$ awk -F"|" '
BEGIN{h="FName|LName|Gender|Company|Branch|Bday|Salary|Age";split(h,a,"|")}
{
  s=$1" "$2" "$4" Missing Field/s: "
  for(i=1;i<NF;i++) {
    if (!$i) {s=s" "a[i];f=1}
  }
}
f{print s;f=0}' file
eeee asdg gggg Missing Field/s:  Salary Age
aara bdbm kkkk Missing Field/s:  Salary
aera bprb cccc Missing Field/s:  Bday
$

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script to read specific lines in a file

I have a file with contents as follows Record 1: Rejected - Error on table "DWO"."P2G_CUST_EVENTS". ORA-00001: unique constraint (DWO.CUST_EVENTS_PK) violated Record 5: Rejected - Error on table "DWO"."P2G_CUST_EVENTS". ORA-00001: unique constraint (DWO.CUST_EVENTS_PK) violated Record 6:... (5 Replies)
Discussion started by: varshanswamy
5 Replies

2. Windows & DOS: Issues & Discussions

Filter data from text file

Hi All We have got a text file, which has data dumped from 60 tables. From these 60 tables of data we need data from 4 tables only. I tried assigning line numbers to filter out data, but it is not working as intended. below is the sample file ----Table1----- 3,dfs,43,df 4,sd,5,edd... (18 Replies)
Discussion started by: b_sri
18 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

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

5. Shell Programming and Scripting

Read data from .csv file through shell script & modify

I need to read data from a file called "test.csv" through shell script where the file contains values like name,price,descriptor etc. There are rows where descriptor (& in some rows name) are written as string & other characters like "car_+" OR "bike*" etc where it should contains strings like... (3 Replies)
Discussion started by: raj100
3 Replies

6. 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

7. UNIX for Beginners Questions & Answers

Shell - Read a text file with two words and extract data

hi I made this simple script to extract data and pretty much is a list and would like to extract data of two words separated by commas and I would like to make a new text file that would list these extracted data into a list and each in a new line. Example that worked for me with text file... (5 Replies)
Discussion started by: dandaryll
5 Replies

8. 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

9. Shell Programming and Scripting

How to get the shell script to read the .txt file as an input/data?

i have written my shell script in notepad however i am struggling to pass the data file to be read to the script the data file is of .txt format. My target is to run the shell script from the terminal and pass 3 arguments e.g. polg@DESKTOP-BVPDC5C:~/CS1420/coursework$ bash valsplit.sh input.txt... (11 Replies)
Discussion started by: Gurdza32
11 Replies

10. UNIX for Beginners Questions & Answers

Shell script to filter certain lines from a file

hi~ i need script on AIX. and have a text file following : create aa 1 2 3 from a@a; create bb from b; create cc 3 4 5 6 6 7 from c@c; (7 Replies)
Discussion started by: tomato00
7 Replies
Validation::Class::Field(3pm)				User Contributed Perl Documentation			     Validation::Class::Field(3pm)

NAME
Validation::Class::Field - Field Object for Validation::Class Classes VERSION
version 7.70 SYNOPSIS
package SomeClass; use Validation::Class; package main; my $class = SomeClass->new; ... my $field = $class->get_field('some_field_name'); $field->apply_filters; $field->validate; # validate this only $field->errors->count; # field-level errors 1; DESCRIPTION
Validation::Class::Field is responsible for field data handling in Validation::Class derived classes, performs functions at the field-level only. This class automatically creates attributes for all acceptable field directives as listed under "DIRECTIVES" in Validation::Class::Prototype. ATTRIBUTES
errors The errors attribute is a Validation::Class::Errors object. METHODS
new my $self = Validation::Class::Field->new({ name => 'some_field_name' }); AUTHOR
Al Newkirk <anewkirk@ana.io> COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Al Newkirk. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-06-28 Validation::Class::Field(3pm)
All times are GMT -4. The time now is 04:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy