To get the exact column data


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To get the exact column data
# 1  
Old 12-21-2011
To get the exact column data

Hi All,
I have a input file contains below data

HTML Code:
crw-r--r--    1 oracle   dba          34, 10 Nov 26 11:50 asm_aue2cu_arch01
crw-r--r--    1 oracle   dba          34,  9 Dec  8 11:00 asm_aue2cu_data01
crw-r--r--    1 oracle   dba          34, 16 Nov 25 20:25 asm_bdeccu_arch01
crw-r--r--    1 oracle   dba          34, 15 Dec  8 11:00 asm_bdeccu_data01
crw-r--r--    1 oracle   dba          34, 20 Dec  8 11:00 asm_bdeccu_data03
crw-r--r--    1 oracle   dba          34, 18 Nov 25 19:33 asm_bneccu_arch01
crw-r--r--    1 oracle   dba          34, 17 Dec  8 09:00 asm_bneccu_data01
crw-r--r--    1 oracle   dba          34, 12 Nov 25 18:24 asm_hke2cu_arch01
crw-r--r--    1 oracle   dba          34, 11 Dec  8 11:00 asm_hke2cu_data01
crw-r--r--    1 oracle   dba          34,  8 Nov 26 11:22 asm_ineccu_arch01
crw-r--r--    1 oracle   dba          34,  7 Dec  8 11:00 asm_ineccu_data01
crw-r--r--    1 oracle   dba          34, 14 Nov 26 12:39 asm_twe2cu_arch01
crw-r--r--    1 oracle   dba          34, 13 Dec  8 10:00 asm_twe2cu_data01
I want the output as below

HTML Code:
aue2cu   arch
aue2cu   data
bdeccu   arch
bdeccu   data
bneccu   arch
bneccu   data
hke2cu   arch
hke2cu   data
ineccu   arch
ineccu   data
twe2cu   arch
twe2cu   data
currently i have executed the below command but the output contains number in the last column i want to supress that .. pls share your ideas how to do it ?

HTML Code:
# cat input.txt | awk '{print $NF}' | awk -F_ '{print $2,"\t",$3}'
 
aue2cu   arch01
aue2cu   data01
bdeccu   arch01
bdeccu   data01
bneccu   arch01
bneccu   data01
hke2cu   arch01
hke2cu   data01
ineccu   arch01
ineccu   data01
twe2cu   arch01
twe2cu   data01
 
Regards
Kannan
# 2  
Old 12-21-2011
Code:
$ nawk -F_ '{a=($(NF-1)"\t"substr($NF,0,4)); print a}' infile

This User Gave Thanks to jayan_jay For This Post:
# 3  
Old 12-21-2011
Thanks a lot Jay its working !!!

Regards
Kannan
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to insert data into black column( Secound Column ) in excel (.XLSX) file using shell script?

Source Code of the original script is down below please run the script and try to solve this problem this is my data and I want it column wise 2019-03-20 13:00:00:000 2019-03-20 15:00:00:000 1 Operating System LAB 0 1 1 1 1 1 1 1 1 1 0 1 (5 Replies)
Discussion started by: Shubham1182
5 Replies

2. Shell Programming and Scripting

Change data in one column with data from another file's column

Hello, I have this file outputData: # cat /tmp/outputData __Capacity^6^NBSC01_Licences^L3_functionality_for_ESB_switch __Capacity^2100^NBSC01_Licences^Gb_over_IP __Capacity^1837^NBSC01_Licences^EDGE_BSS_Fnc __Capacity^1816^NBSC01_Licences^GPRS_CS3_and_CS4... (1 Reply)
Discussion started by: nypreH
1 Replies

3. Shell Programming and Scripting

Delete column with exact string in specific col

Hi, my file structur looks like File structure looks: GeneID protein_gi Symbol 1246500 10954455 repA1 1246501 10954457 repA2 1246502 10954458 leuA But some of the cases do not have record for protein id. for example: 1343044 - orf01 I want to remove those rows. But I tried awk... (9 Replies)
Discussion started by: smitra
9 Replies

4. Shell Programming and Scripting

Compare 2 files and match column data and align data from 3 column

Hello experts, Please help me in achieving this in an easier way possible. I have 2 csv files with following data: File1 08/23/2012 12:35:47,JOB_5330 08/23/2012 12:35:47,JOB_5330 08/23/2012 12:36:09,JOB_5340 08/23/2012 12:36:14,JOB_5340 08/23/2012 12:36:22,JOB_5350 08/23/2012... (5 Replies)
Discussion started by: asnandhakumar
5 Replies

5. 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

6. Shell Programming and Scripting

finding number in exact column

Dear all, I want to find a number in exact column but I don't know how to do it. Here is the thing, data is shown below, and I want to find 416 in the first column and print it out, how should I deal with it? Thank you very much! ab33 50S01S 958 279.068999 67.251013 -150.172544 67.250000... (5 Replies)
Discussion started by: handsonzhao
5 Replies

7. Shell Programming and Scripting

print column value after exact match of variables in file

I have file like below summit hvar_rgrpd_10d_hvams17_ _kgr_prod.rec checksum checksum us europe summit hvar_rgrpd_10d_hvams17_ _kgr_prod.xml var summit us ... (5 Replies)
Discussion started by: manas_ranjan
5 Replies

8. Windows & DOS: Issues & Discussions

Split Data in one column into 2 column in Excel using DOS or VBScript

Hi I have some data in my Excel File.However all the data is in one single column.I want to split it into two columns. Current Data: 1,Hi Everyone,I am 7,New To Dos,And 17,VB Script,i could 110,have tried this thing 1800,in UNIX Desired Output CELL1|CELL 2 1 |Hi... (3 Replies)
Discussion started by: dashing201
3 Replies

9. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

10. Shell Programming and Scripting

AWK seach for exact word in certain column

Can anyone help me how I will extract all lines in a file where the word "worker" or "co-worker" in 2nd column exist. There are also word in 2nd column like "workers" or "worker2" but I don't want to display those lines. Appreciate any help in advance! Thank you! (5 Replies)
Discussion started by: Orbix
5 Replies
Login or Register to Ask a Question