FNR>2 is not working and unable to extract data from a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting FNR>2 is not working and unable to extract data from a file
# 1  
Old 09-14-2011
FNR>2 is not working and unable to extract data from a file

Hi,
I have a file in windows environment and moved to UNIX through FTP (ASCII format).
The file is having with tab delimited file.

Code:
awk ‘FNR>2' file_cust*.txt >>filnal.txt

I have the same file in production; it is working fine with the same procedure. Once we receive the file in windows environment and send it to UNIX through FTP.

But in another environment it is not reading the records from the file.


Code:
awk ‘FNR>2' file_cust.txt file_cust_0001201201.txt >>filnal.txt


this is the file I am getting the problem- file_cust_0001201201.txt

checked in the file any special charters are present in the file. -No special charters, No control-m charters, No additional spaces after each row.


I am unable to figure out the issue whether it is related with the file or command.

If it is a file any checks need to do on the file. Any help greatly appreciated

Thanks -onesuri
# 2  
Old 09-14-2011
awk does not like windows text files - You need to strip the trailing carriage return from \r\n to just a \n.

dos2unix (or called dos2ux sometimes) does just that.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare 2 files and extract the data which is present in other file - awk is not working

file2 content f1file2 content f1,1,2,3,4,5 f1,2,4,6,8,10 f10,1,2,3,4,5 f10,2,4,6,8,10 f5,1,2,3,4,5 f5,2,4,6,8,10awk 'FNR==NR{a;next}; !($1 in a)' file2 file1output f10,1,2,3,4,5 f10,2,4,6,8,10 f5,1,2,3,4,5 f5,2,4,6,8,10awk 'FNR==NR{a;next}; ($1 in a)' file2 file1output nothing... (4 Replies)
Discussion started by: gksenthilkumar
4 Replies

2. Red Hat

Unable to extract .gz file using gunzip

Linux 3.8.13-16.2.1.el6uek.x86_64 #1 SMP Thu Nov 7 17:01:44 PST 2013 x86_64 x86_64 x86_64 GNU/Linux Hi all, I am unable to extract .gz file using gunzip Used the following command to create the .gz file: nohup tar -cvpf - 11.2.0.4 | gzip -c >... (3 Replies)
Discussion started by: a1_win
3 Replies

3. Shell Programming and Scripting

Extract data from a file

Hi , I am having a file which is PIPE delimited like this : file.txt aus|start|10:00:00 nz|start|11:00:00 aus|end|10:10:00 us|start|10:00:00 nz|end|11:10:00 us|end|11:00:00 . . . I want to extract an output file like this based on start time and end time for each countries: (9 Replies)
Discussion started by: rohit_shinez
9 Replies

4. Shell Programming and Scripting

Extract data from a file

I have a text file that contains the following data. For example, aa.txt has some numbers. I need to extract the continuous numbers(minimum 3 numbers) from it.How can I do this with awk? >aa.txt 31 35 36 37 38 39 44 169 170 173 174 175 177 206 >1a.txt 39 (5 Replies)
Discussion started by: rahmanabdulla
5 Replies

5. Shell Programming and Scripting

Extract data from a file

Hello All, I have a small xml file which looks like below: <Check:defaultval Val="crash" value="crash_report_0013&#xA;generate_check_0020 generate_check_0022&#xA;&#xA;This is where the fault is."/> <Check:defaultval Val="crash" value="crash_report_1001&#xA;generate_check_1001... (9 Replies)
Discussion started by: suvendu4urs
9 Replies

6. Shell Programming and Scripting

Extract header data from one file and combine it with data from another file

Hi, Great minds, I have some files, in fact header files, of CTD profiler, I tried a lot C programming, could not get output as I was expected, because my programming skills are very poor, finally, joined unix forum with the hope that, I may get what I want, from you people, Here I have attached... (17 Replies)
Discussion started by: nex_asp
17 Replies

7. UNIX for Dummies Questions & Answers

Unable to extract bz2-00 file

I have a file having name smthing.tar.bz2-00 I am trying to unzip it using tar -xvjf "name" But I am not able to unzip it. PLease advise for the issue. (3 Replies)
Discussion started by: nixhead
3 Replies

8. Shell Programming and Scripting

extract data from file

I m new to shell scripting & i need a help.... i have file like.... Name := sachin address:=something phone:=111 ... Note: There might be or not space between Name & := and between := & sachin. I need to extract the data from each line of file as var1=Name value1=sachin same for... (13 Replies)
Discussion started by: ps_sach
13 Replies

9. Shell Programming and Scripting

Extract data from file

Dear All , I am posting first time in this forum . Please ignore my mistakes . I am learning Unix and i need help to extract specific data from file . 1. I want to grep number of fails from log . The file contains "fails" word in line if test cases are failed . 2. The log contains... (20 Replies)
Discussion started by: getdpg
20 Replies

10. Shell Programming and Scripting

extract data from file

My file in ksh consists of message data of varying lengths (lines), separated with headers. I would like to find a string from this file, and print out the whole message data including the headers. my plan of attack is to search the strings, print the top header, and print the whole message... (2 Replies)
Discussion started by: apalex
2 Replies
Login or Register to Ask a Question