2 columns of data


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers 2 columns of data
# 1  
Old 11-07-2012
Wrench 2 columns of data

Hello folks,

I have been learning Linux for a couple of weeks, and i am facing a simple problem that i couldn't resolve.
I have a file with 2 columns of data, the first coloumn always has text, and the second coloumn sometimes has text and, sometimes blank.
I want to make a new file with the first column hits that match a blank coloumn.

I've bene trying to use cut and grep but couldn't find a formula to indicate empty lines with them.
I hope that was clear Smilie

Thanks,
Error404
# 2  
Old 11-07-2012
Show the input you have and the output you want.

Don't just describe it, show it.
# 3  
Old 11-07-2012
the data is huge, i can't show it unfortunately, but here's an example that shows the issue, i have a tab-separated file of 2 coloumns (assume --- is tab, because the website ignores spaces)

APPLE --- milk/water
BANANA ---
ORANGE --- OIL
TOMATO ---
Potato --- Water/OIL
Garlic ---
onion --- Butter

and so on....

I want to select BANANA, TOMATO, and Garlic, and copy them into a new file.

Thanks
-Error404

Last edited by Corona688; 11-07-2012 at 02:02 PM..
# 4  
Old 11-07-2012
Try this:-
Code:
awk ' { if($2 ~ /^ *$/ ) print $1; } ' input_file > new_file

This User Gave Thanks to Yoda For This Post:
# 5  
Old 11-07-2012
YeeeHaaa!!! Smilie) thaanks mate, it worked perfectly Smilie :hat:
# 6  
Old 11-07-2012
Quote:
Originally Posted by Error404
the data is huge, i can't show it unfortunately, but here's an example that shows the issue, i have a tab-separated file of 2 coloumns (assume --- is tab, because the website ignores spaces)
I could have fixed your output if you'd simply pasted it, because formatting will be followed inside code tags ( Image button ). Now that you've edited it to that, I no longer know what you wanted it to look like.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting data from specific columns

i have a file (csv or txt or anything which has 4 columns (id,name,number,location) and it contains data. i want to convert the data of specific columns like name to ooooo and number to 88888 matching the field length of that columns. for example if name column has anthony which is 7, it should... (2 Replies)
Discussion started by: prajaktaraut
2 Replies

2. Shell Programming and Scripting

Bash formatting data into columns

Hi guys, I'm trying to create a table of aggregated data using just bash commands. My data is in three columns, for example: 2014-01-01 testA 64 2014-01-01 testB 27 2014-02-01 testA 31 2014-02-02 testB 29 2014-02-02 testC 12 And the result I am looking for is: ... (4 Replies)
Discussion started by: mccmjc
4 Replies

3. Shell Programming and Scripting

Comparision of two data columns in different files

Hi All, I have a requirement to compare data column which is the last field in two different files and trigger and alert if the difference is greater than 1 for each row. File1 Jan Acount1 2014 11223 Feb Account2 2014 2345 Mar Account3 2014 1233 File2 Jan Account1 2014... (1 Reply)
Discussion started by: Naresh Babu
1 Replies

4. Shell Programming and Scripting

Help need to subtract the data from 2 columns

space_used.lst /dev/vx/dsk/A06487-S01-c4e3s-ORACLE-dg/oradata01 505G 318G 175G 65% /dborafiles/nethealth21/PV/oradata01 /dev/vx/dsk/A06487-S01-c4e3s-ORACLE-dg/oradata02 505G 433G 67G 87% /dborafiles/nethealth21/PV/oradata02 /dev/vx/dsk/A06487-S01-c4e3s-ORACLE-dg/oradata03 507G 422G 79G 85%... (4 Replies)
Discussion started by: sathik
4 Replies

5. Shell Programming and Scripting

Transpose Data from Columns to rows

Hello. very new to shell scripting and would like to know if anyone could help me. I have data thats being pulled into a txt file and currently have to manually transpose the data which is taking a long time to do. here is what the data looks like. Server1 -- Date -- Other -- value... (7 Replies)
Discussion started by: Mikes88
7 Replies

6. UNIX for Dummies Questions & Answers

Suggestion to convert data in rows to data in columns

Hello everyone! I have a huge dataset looking like this: nameX nameX 0 1 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 1 2 2 2 ............... nameY nameY 2 2 2 2 2 2 2 2 2 2 1 2 2 2 1 2 2 2 ..... nameB nameB 0 1 2 2 2 2 2 2 2 2 1 2 2 2 1 2 2 2 ..... (can be several thousands of codes) and I need... (8 Replies)
Discussion started by: kush
8 Replies

7. Shell Programming and Scripting

Data in Rows to Columns

Hi, I am a beginner in bash&perl. I have data in form of:- A 1 B 2 C 3 D 4 E 5 I would like your help to find a simple way to change it to :- A B C D E 1 2 3 4 5 Any help would be highly appreciated. (8 Replies)
Discussion started by: umaars
8 Replies

8. Shell Programming and Scripting

grep required data from two columns

hello, I have output from a command and I need to filter some info out of that. I tried awk command but I can not grep what I am looking for: Following is the output and I need to capture "disabled" for each volume from first column and report: # vol status Volume State ... (2 Replies)
Discussion started by: za_7565
2 Replies

9. Shell Programming and Scripting

sort data in different columns

Hello all: i have list with the following format Id Name Iid Value 0x4440001 customerCode 44077 0x11d2a PrimaryAddress 57.217.41.201 0x129fa ... (15 Replies)
Discussion started by: mogabr
15 Replies

10. Shell Programming and Scripting

lining up columns of data

Hi, I have two files containing clumns of data and now I'd like to merge them into one. File one, 1.dat, contains 7 data columns and file two, 2.dat, contains 6 data columns I need a third file, 3.dat, containing on the first 7 columns the data of file 1.dat and on the 8th, 9th etc the 6... (2 Replies)
Discussion started by: pau
2 Replies
Login or Register to Ask a Question