How to check field formatting of input file?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to check field formatting of input file?
# 1  
Old 09-27-2010
How to check field formatting of input file?

Hi,

I had input file with below data,
abcdefghij;20100903040607;1234567891;GLOBAL;

Having values of fields with seperated by semi-colon (Smilie and ended with line feed (\n).
Through shell script, how can I check the field formatting?
Thanks in advance.
# 2  
Old 09-27-2010
what do u want to check in formatting ?

only number of fields or you want to verify each fields ?
# 3  
Old 09-28-2010
I want to check below 3 things,
1] number of fields in each line
2] Fields should be seperated by semi-colon
3] Line should be ended with line feed \n

Could you please help me out to write shell script for this? Thanks in advance.
# 4  
Old 09-28-2010
You read awk guide first, understand what's the meaning of :

Code:
FS
NF

then you should know the answer.
# 5  
Old 09-28-2010
thanks for reply. but, I need to write a shell script, not awk.
# 6  
Old 09-28-2010
Hi, could you show what you have tried so far and where you are stuck?
# 7  
Old 09-28-2010
I tried below code, but not get expected output.
Code:
while read line ; do
  echo "$line"|wc -w
done < $FILE


Last edited by Franklin52; 09-28-2010 at 07:02 AM.. Reason: Use code tags please!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to check field value from a file records

I need a script to check the records in a file , if any value match transfer the record in error.txt file. 1- If any of the any field value is NULL(nothing in this field) Record1|Record2|Record3|Record4|Record5|DATE1|DATE2 Example: 11111111|22222222|NULL|12|444|27042018|27042018... (8 Replies)
Discussion started by: vivekn
8 Replies

2. Shell Programming and Scripting

Check if 2 input values exists in a file

I have a file number.txt.I need to get 2 inputs from the terminal like a=100 and b=200.If a and b are there in the file,then check if a < b,print "less".If a is not there in the file,print "a is missing" or if b is not there in the file,print "b is missing". number.txt: 100 200 300 (2 Replies)
Discussion started by: aneeta13
2 Replies

3. Shell Programming and Scripting

Check input file with different criteria

HI Input file.txt ABCDE1 JFHFJFJF3 10 ABCDE2 JFHFJFJF5 20 ABCDE3 JFHFJFJF5 30 ABCDE4 JFHFJFJF6 - ABCDE5 JFHFJFJF6 20 ABCDE6 JFHFJFJF6 90 ABCDE7 JFHFJFJF6 9 ABCDE8 JFHFJFJF6 I want to check third column if data missing or wrong data the echo massage and out from script. 1.... (8 Replies)
Discussion started by: pareshkp
8 Replies

4. UNIX for Dummies Questions & Answers

Find and add a field for an input file

Hello Sir/Madam, I'm new to UNIX and wondering if I can process a find & add using AWK command in UNIX? requirements: I have to find *.JPG field for each line in the input file and add it as a separate field for each line.. for ex: 0000684631,E,3088017,7... (10 Replies)
Discussion started by: V1l1h1
10 Replies

5. Shell Programming and Scripting

Input handling and formatting input to shell

i want to get input and depending on it create new commands for input to expect. But problem is that after giving date or month as 01-09 it is interpretation as 1-9 echo -n "ENTER DATE " read d1 echo -n "ENTER MONTH " read m1 echo -n "ENTER YEAR" read y1 o=1 i=1 d2=`expr $d1... (1 Reply)
Discussion started by: sagar_1986
1 Replies

6. Shell Programming and Scripting

Formatting and combining fields of the input file

Hi, I have a file of the following format: AV 103 AV 104 AV 105 AV 308 AV 517 BN 210 BN 211 BN 212 BN 218 and the desired output is : AV 103-105 3 AV 308 1 AV 517 1 BN 210-212 3 (5 Replies)
Discussion started by: rochitsharma
5 Replies

7. Shell Programming and Scripting

Input file check

Hi, I have a script which runs daily. It gets 3 input files test1,test2,test3. I want to do a validation in my script to make sure i have all the 3 files available before running. If any one of the file is missing i want to break the script. Could you please help me with this request. ... (1 Reply)
Discussion started by: Krrishv
1 Replies

8. Shell Programming and Scripting

avoid open file to check field.

Hi Everyone, # cat a.txt 94,aqqc,62345907, 5,aeec,77, # cat 1.pl #!/usr/bin/perl use strict; use warnings; use Date::Manip; open(my $FA, "/root/a.txt") or die "$!"; while(<$FA>) { chomp; my @tmp=split(/\,/, $_); if (index($tmp, "qq") ne -1) { ... (4 Replies)
Discussion started by: jimmy_y
4 Replies

9. Shell Programming and Scripting

check presence of input file

My script is taking a file "input.in" as input for running the script. My worry is that i need to execute the script only if the file is present, if it's not don't perform the next commands. Just to have a check at the beginning of the script : If "input.in" exists, then go on. If it's does not... (4 Replies)
Discussion started by: newpromo
4 Replies

10. Shell Programming and Scripting

check for the value of one particular field and give output in a different file

hi i need to check for the value of one particular field : in the output file. the file may contain many such records as below how to ???? *** Throttled with base name + key params! : : -518594328 : les.alarm.LBS12005 : les.alarm.LBS12005 : les : lessrv1 : les : 2328 : 0... (7 Replies)
Discussion started by: aemunathan
7 Replies
Login or Register to Ask a Question