I need extract column pattern in file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting I need extract column pattern in file
# 1  
Old 06-27-2012
I need extract column pattern in file

Hi, it's my first time in this site.

I've a file that look likes

Code:
Edges 21 82
Edges 3 22
Edges 34 12
Edges 1 24
Edges 6 2
Edges 12 22

etc. I need extract just the second and third column with the space between them. ThanksSmilie

Moderator's Comments:
Mod Comment Please use code tags next time for your code and data.

Last edited by radoulov; 06-27-2012 at 07:32 AM..
# 2  
Old 06-27-2012
Code:
 
awk '{print $2,$3}' file.txt

# 3  
Old 06-27-2012
Thank
# 4  
Old 06-27-2012
Code:
sed 's/[^ ]* //' file

# 5  
Old 06-27-2012
Code:
cut file.txt -d' ' -f2,3

Moderator's Comments:
Mod Comment Video tutorial on how to use code tags in The UNIX and Linux Forums.

Last edited by radoulov; 06-27-2012 at 07:32 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

If pattern in column 3 matches pattern in column 2 (any row), print value in column 1

Hi all, I have searched and searched, but I have not found a solution that quite fits what I am trying to do. I have a long list of data in three columns. Below is a sample: 1,10,8 2,12,10 3,13,12 4,14,14 5,15,16 6,16,18 Please use code tags What I need to do is as follows: If a... (4 Replies)
Discussion started by: bleedingturnip
4 Replies

2. UNIX for Beginners Questions & Answers

Extract file name based on the pattern

Hello All, I have multiple files in a hadoop /tmp/cloudera directory. Filename are as follows ABC_DATA_BAD5A_RO_F_20161104.CSV ABC_DATA_BAD6C_VR_F_20161202.CSV ABC_DATA_BAD7A_TR_F_20162104.CSV ABC_DATA_BAD2A_BR_F_20161803.CSV ABC_DATA_BAD3T_KT_F_20160106.CSV I just need filenames... (6 Replies)
Discussion started by: prajaktaraut
6 Replies

3. Shell Programming and Scripting

Extract pattern from file

hi, file is having entries like below NRTMRC1=some value NRTSMO1=some value NRTMAA1=some value NRTSCO1=some value NRTSSMA1=some value NRTMRC11=some value NRTSMO11=some value NRTMAA11=some value NRTSCO11=some value NRTSSMA11=some alue NRTSSMMAA11=some value MNRMRC1=some value... (4 Replies)
Discussion started by: deepakiniimt
4 Replies

4. Shell Programming and Scripting

extract a pattern from a xml file

Hello All, I want to write a shell script for extracting a content from a xml file the xml file looks like this: <Variable name="moreAxleInfo"> <type> <Table> <type> <NamedType> <type> <TypeRef... (11 Replies)
Discussion started by: suvendu4urs
11 Replies

5. Shell Programming and Scripting

Extract a pattern from xml file

Hi, In a single line I have the below xml content <lst name="responseHeader"><int name="status">0</int><int name="QTime">1</int></lst><lst name="status"><lst name=""><str name="name"/><str name="instanceDir">/var/www/search/current/Search/solr/./</str><str... (5 Replies)
Discussion started by: ashokvpp
5 Replies

6. Shell Programming and Scripting

Replace column that matches specific pattern, with column data from another file

Can anyone please help with this? I have 2 files as given below. If 2nd column of file1 has pattern foo1@a, find the matching 1st column in file2 & replace 2nd column of file1 with file2's value. file1 abc_1 foo1@a .... abc_1 soo2@a ... def_2 soo2@a .... def_2 foo1@a ........ (7 Replies)
Discussion started by: prashali
7 Replies

7. Shell Programming and Scripting

extract pattern from csv file

hi, i have a situation where i have a csv file in the format date,name eg: 1284631889869,a 1284631889879,b 1284631889459,c . . . . . . . now i take a time and an interval from user. (5 Replies)
Discussion started by: niteesh_!7
5 Replies

8. Shell Programming and Scripting

Extract a pattern from file

In my file I have a pattern ri="234" value of ri can be any i want to find this pattern in file replace this value of ri with another value stored in some variable say newri Please tell how to do it? Thanks in Advance (10 Replies)
Discussion started by: pasricha.kunal
10 Replies

9. Shell Programming and Scripting

Extract specific pattern from a file

Hi All, I am a newbie to Shell Scripting. I have a File The Server Name XXX002 ------------------------- 2.1 LAPD Iface Id Link MTU Side ecc_3_1 4 Up 512 User ecc_3_2 5 Up 512 User The Server Name XXX003 ------------------------- 2.1 LAPD (4 Replies)
Discussion started by: athreyavc
4 Replies

10. Shell Programming and Scripting

How to extract only first column from the file

Dear All, I have a file name pointer.unl. It's contains the information below: O|A|4560333089|PBS|AU1|01/04/2003|30/04/2006|D|IGCD| O|A|4562222089|PBN|AU1|01/02/2006|31/01/2008|D|04065432| O|A|3454d00089|PKR|AU1|01/03/2008||R|sdcdc| I only need to extract first... (11 Replies)
Discussion started by: selamba_warrior
11 Replies
Login or Register to Ask a Question