Fetch particular characters from a column


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Fetch particular characters from a column
# 1  
Old 07-25-2012
Fetch particular characters from a column

Hi
I wanted to fetch particular characters from a column.I have a file having columns separated by pipe operator.
The contents of the file are
Code:
 Task            | Task started on a component            | B678C56D-96DA-4FFC-B40E-9A032A2EB12E-0000004          | service.adapter:UCF Version Creator

I want 3rd and fourth column as output but from 3rd column only first 37 characters are needed
the output should be:
Code:
B678C56D-96DA-4FFC-B40E-9A032A2EB12E| service.adapter:UCF Version Creator

# 2  
Old 07-25-2012
Code:
awk -F'|' '{gsub(/ */,"",$3); print substr($3,1,36) "|" $4}' input

# 3  
Old 07-25-2012
Thanku It solved my purpose
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Group by a column and first 2 characters of another

Hello all, I want to consolidate my data group by cities into 4 rolled up code categories (first 2 characters of 2nd col), namely PR, GR, TY and others. CHICAGO PR1 CHICAGO GR3 CHICAGO GR4 CHICAGO HT5 CHICAGO HT6 CHICAGO TY5 HOUSTON PR3 HOUSTON PR9 HOUSTON TY4 HOUSTON HJ5... (1 Reply)
Discussion started by: jalaj841
1 Replies

2. Shell Programming and Scripting

Fetch parent value based on column values

Hi All, I am trying to achieve the below logic, could you please help me in this. In second row 2nd column I've Value JC2 and the same JC2 is 4th row 1st column.So I need to replace JC2 value in 4th row with JC2 2nd row's 1st column. Input: Job1,JC1 Job1,JC2 Job1,JC3 JC2,JA1... (6 Replies)
Discussion started by: unme
6 Replies

3. Shell Programming and Scripting

Remove the first character from the fourth column only if the column has four characters

I have a file as follows ATOM 5181 N AMET K 406 12.440 6.552 25.691 0.50 7.37 N ATOM 5182 CA AMET K 406 13.685 5.798 25.578 0.50 5.87 C ATOM 5183 C AMET K 406 14.045 5.179 26.909 0.50 5.07 C ATOM 5184 O MET K... (14 Replies)
Discussion started by: hasanabdulla
14 Replies

4. Shell Programming and Scripting

Delete last characters in each column

I need to delete the last 11 characters from each number and they are all in the same line (each is in a different column): -6.89080901827020800000 3.49348891708562325136 1.47988367839905286876 -2.29707635413510400000 -3.49342364708562325136 -4.43758473239905286876 -2.29707635413510400000... (14 Replies)
Discussion started by: rogeriog.em
14 Replies

5. Shell Programming and Scripting

Fetch the lines which contains special characters

Hi All, My source file contains special characters(Latin characters).I need to fetch only the lines which contains the special characters. The problem is i don't know which all latin/special characters can come in the source. Is there anyway to extract the lines which contain letters other... (3 Replies)
Discussion started by: joe!!
3 Replies

6. Shell Programming and Scripting

Match first column entries precisely and fetch whatever in front of it

Hi all I have 2 files: first file AABC TTYP JKBH CVBN NHJK KJHM Second file is AABC,XCYU,JUHD Alllele1 GACXT It is approved study TTYP,JKBH Allele2 PPRD It is clinical trial study JKBH Allele2 PPRD ... (5 Replies)
Discussion started by: Priyanka Chopra
5 Replies

7. Shell Programming and Scripting

How to print the first 7 characters of each column

Hello all, I have a data like this: X:04252 X:05524 X:04176 X:05509 X:05524 X:04674- X:1662912 X:10181 X:16491 X:05506 X:05216- X:05488 X:46872 X:08471 X:04834 X:30170 The except result is like this: X:04252 X:05524 X:04176 X:05509 X:05524 X:04674 X:16629 X:10181... (3 Replies)
Discussion started by: yhkoo
3 Replies

8. Shell Programming and Scripting

Match words and fetch data in front of it in second column

Hi all, I have 2 files one file contain data like this in one column AST3 GSTY4 JST3 second file containign data like this in 2 columns AST3(PAXXX),GSTY4(PAXXY) it is used in diabetes KST4 it is used in blood... (6 Replies)
Discussion started by: manigrover
6 Replies

9. Ubuntu

How to compare two columns and fetch the common data with additional column

Dear All, I am new to this forum and please ignore my little knowledge :p I have two types of data (a subset is given below) data version 1: 439798 2 1 451209 1 2 508696 2 1 555760 2 1 582757 1 2 582889 1 2 691827... (2 Replies)
Discussion started by: evoll
2 Replies

10. Shell Programming and Scripting

Help to fetch first two characters from a word in perl

Hi All, I have a word "DE_PR_Package__Basic" , i need to check if the first two characters of this words is DE or something else using perl script. Can anyone pls let me know how to proceed? Thanks in advance. Giri! (3 Replies)
Discussion started by: girish.raos
3 Replies
Login or Register to Ask a Question