take last column includning spaces also


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting take last column includning spaces also
# 1  
Old 10-31-2008
Java take last column includning spaces also

hi i have a file with content, i need to extract last column from each line including spaces and form a string
i used echo "$LINE" | awk '{print $1,$2}' | grep '^\[' | awk '{printf("%-16s",$2)}' , but i am not getting the last 000000 and spaces



[00000000:00000000] 33333030 30303030 30303030 CTL1330000000000
[00000016:00000010] 44453932 33353237 36333030 0000DE9235276300
[00000032:00000020] 30305453 30353934 44453932 008000TS0594DE92
[00000048:00000030] 3633414D 45583030 30302E54 352763AMEX0000.T
[00000064:00000040] 20202020 20202020 20202020 RN
[00000080:00000050] 20203030 38303030 30303030 008000000
[00000096:00000060] 30303030 30300D 000000.


please help

thanks
Satay
# 2  
Old 10-31-2008
Code:
awk '/^\[/ {print $NF}' infile

# 3  
Old 10-31-2008
hi zaxxon, thanq for ur reply
i did not under stand, can u elaborate
# 4  
Old 10-31-2008
Code:
/^\[/

This pattern should be clear - you used it yourself(?). Since it's in front of the curled brackets, it triggers the commands in the curled brackets when found/true.
Code:
{print $NF}

This one prints out the field and NF is the number of fields it replaces NF with the number of fields in this line which is the last field then automatically.
# 5  
Old 10-31-2008
thanx zaxxon , can u tell how to form a string with the above data incoding spaces lke

CTL13300000000000000DE9235276300008000TS0594DE92352763AMEX0000.TRN 008000000 000000.
i am trying a lot , but i could not ,please help

Satya
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Search spaces in 5th column in large file

i have a file having 5 columns with more than million records. And i want to search using UNIX command to find if there are any spaces in 5th column. any please help. (1 Reply)
Discussion started by: sivakumar.p
1 Replies

2. Shell Programming and Scripting

Include information and change column order while maintaing white spaces

I need to change the order of the columns of data that looks like this: The original data is in 6 tab-separated columns. FACTSHEET factsheet NN 1 5 DEP WHAT what WP 2 3 SBJ IS be VBZ 3 1 NMOD AIDS AIDS NP ... (1 Reply)
Discussion started by: owwow14
1 Replies

3. Shell Programming and Scripting

How to awk or grep the last column in file when date on column contains spaces?

Hi have a large spreadsheet which has 4 columns APM00111803814 server_2 96085 Corp IT Desktop and Apps APM00111803814 server_2 96085 Corp IT Desktop and Apps APM00111803814 server_2 96034 Storage Mgmt Team APM00111803814 server_2 96152 GWP... (6 Replies)
Discussion started by: kieranfoley
6 Replies

4. UNIX for Dummies Questions & Answers

[SOLVED] splitting a single column(with spaces) into multiple rows

Hi All, My requisite is to split a single column of phonemes seperated by spaces into multiple rows. my input file is: a dh u th a qn ch A v U r k my o/p should be like: adhu a dh u (3 Replies)
Discussion started by: girlofgenuine
3 Replies

5. Shell Programming and Scripting

How to print the last column of the list contain filenames with spaces.

Hi experts, I have the following data: I want the last filed in the output. How to print the last field , It contains the file names and few filenames with white spaces . -rw-r--r-- 1 root root 0 2010-04-26 16:57 file1 2space_File.txt -rw-r--r-- 1 root root 0 2010-04-26... (2 Replies)
Discussion started by: rveri
2 Replies

6. Shell Programming and Scripting

Extracting 3rd column using awk from file with spaces.

BAQ001 /dev/rdsk/c2t0d7 1C13 (M) RW 69053 The line above is from a text file. I want to use awk to extract the value in the third column 1C13. I just can't seem to get the syntax right or something. Any help would be appreciated. Thanks, (5 Replies)
Discussion started by: ricnetman
5 Replies

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

8. Shell Programming and Scripting

Use awk to have the fourth column with spaces

Hi Gurus, We have a ftpserver from which we do a dir command and output it to a local file. The content of the ftpfile is: 07-15-09 06:06AM 5466 ABC_123_ER19057320090714082723.ZIP 07-15-09 06:07AM 3801 ABC_123_ER19155920090714082842.ZIP 07-15-09 06:07AM ... (14 Replies)
Discussion started by: donisback
14 Replies

9. Shell Programming and Scripting

need help to remove spaces from first column

Hi, Here is sample data which I have: column#1 column#2 column#3 001A 50005 ROCKER ADJ 00010000100018UTIRR 001A 50020 CRANKSHAFT 0003445ES 001A 52201 SPARKPLUG ... (4 Replies)
Discussion started by: tayyabq8
4 Replies

10. UNIX for Dummies Questions & Answers

removing trailing spaces of a particular column in a file

Hi, I am currently confused. Suppose I have a file something like the one below. 4299|raj Telecommunications|12||||| 4302|anjali International Ltd.|86|ritchie||dong|(000)2890 9993 |(222)4881 3689 4305|フィデュシアリ・ト-スト・インター...ショ...ル投資顧問株式会社 |112||||01-9211-1931 |08-3677-1985 Now... (2 Replies)
Discussion started by: rooh
2 Replies
Login or Register to Ask a Question