If it is empty in column 5


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting If it is empty in column 5
# 8  
Old 05-17-2012
Could it be that the empty field is not the last field?
Code:
awk -F'\t' -v f=file1 '$5==""{print>f; next}1' infile > file2

This User Gave Thanks to Scrutinizer For This Post:
# 9  
Old 05-17-2012
Line endings

Code:
[mute@geek ~]$ file input
input: ASCII text, with CR line terminators
[mute@geek ~]$ awk '{print NR,NF "::\t" $0}' input
1 9::   2       3       4       4       5
[mute@geek ~]$ awk '{print NR,NF "::\t" $0}' RS="\r" input
1 5::   1       2       3       4       5
2 4::   1       2       3       4

# 10  
Old 05-17-2012
yes it worked... something weird was wrong but you guys fixed it. thank you all

Kyle
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read a tab separated file with empty column

Hi all, I'm trying to read a tab separated file and apply some functions on each column. I have an issue with empty column. Exemple: $ #cat with the sed to allow you to see my tab $ cat foo.txt| sed 's/\t/;/g' a;1;x b;;yI wanted to something like that: while read col1 col2 col3 do ... (4 Replies)
Discussion started by: maturix
4 Replies

2. Shell Programming and Scripting

How to grep an empty line in a specific column of a file?

Suppose i have the following data : cat file.txt 12431,123334,55353,546646,14342234,4646,35234 123123,3535,123434,132535,1234134,13535,123534 123213,545465,23434,45646,2342345,4656,31243 2355425,2134324,53425,342,35235,23434,234535 3423424,234234,65465,,2344,35436,234524,234... (7 Replies)
Discussion started by: Ravi Tej
7 Replies

3. Shell Programming and Scripting

print non empty column/field value

I have below file 25-09-2012 24-09-2012 19-09-2012 31-07-2012 30-04-2012 30-03-2012 ASIAEXFVNV N/A CEU 4 DMIRSOA N/A CAS 2 2 2 DMIRSOA N/A MIDMT 2 NFIAL22 N/A HVNY 11 11 11 NFIAL22 N/A NYAL3 11 11 11 NFIAL22 N/A NYCN 11 11 11 ... (4 Replies)
Discussion started by: manas_ranjan
4 Replies

4. Shell Programming and Scripting

sed - insert text if column empty

Hi, I want to insert the text 'Unknown' in 2 specific columns in a csv file (actually | separated) if the column is blank. Its always the same columns. I have tried using sed: sed "s/||/|Unknown|/g" but there are occasion where other fields are blank and they need to be left blank. This... (4 Replies)
Discussion started by: ksexton
4 Replies

5. Shell Programming and Scripting

Retrieve empty value in column

hi guys, how to retrieve "empty" value in column3 and column6 in the following text $ cat myfile.txt COL1 COL2 COL3 COL4 COL5 val1 long_value_name_that_takes_space value4 val5 COL6 COL7 ... (1 Reply)
Discussion started by: kholis
1 Replies

6. UNIX for Dummies Questions & Answers

Filling the empty columns in a fixed column file

Hi, I have a file with fixed number of columns (total 58 columns) delimeted by pipe (|). Due to a bug in the application the export file does not come with fixed number of columns. The missing data columns are being replaced by blank in the output file. In one line I can have 25 columns (33... (1 Reply)
Discussion started by: yale_work
1 Replies

7. Shell Programming and Scripting

Replace empty string on particular column

Hi I would like to replace empty string with a particluar value, any suggessions with awk ? my input file is not delimited with any delimiters input 52001073M8000000004567777 5200107 000000004567778 5200107 000000004567779 52001073M8000000004567789 Expected output... (5 Replies)
Discussion started by: selvankj
5 Replies

8. Shell Programming and Scripting

delete lines with empty second column

hi, I'd like to ask you if you can help me with such surely easy thing - I have some data and need to plot them. I have txt of data in two columns, tab separated, but some second columns are empty. like 1```` 2 1.2`` 3```` 2 4.44` 5````` 6.1```1 how can I erase all the lines... (2 Replies)
Discussion started by: bsco
2 Replies

9. Shell Programming and Scripting

delete empty spaces at specific column

Hi All, If anybody could help me with my scenario here. I have a statement file. Example of some content: DATE DESC Debit Credit Total Rate 02-Jan-08 Lodgement 200.00 1200.00 2.51 14-Sep-07 Withdrawal 50.00 1000.00 ... (8 Replies)
Discussion started by: yonez
8 Replies

10. UNIX for Dummies Questions & Answers

Getting same exit status for empty and non empty file

Hi All, I am checking for a empty input file to do some further action , but I am getting exit status 0 in both the cases , for empty and non empty file both. The value of $? is coming 0 in if part also and else part too. #!/bin/ksh if ]; then echo "data" # exit 0 echo "$?" else... (4 Replies)
Discussion started by: mavesum
4 Replies
Login or Register to Ask a Question