Help on Script of Copy String from column


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help on Script of Copy String from column
# 1  
Old 02-27-2012
MySQL Help on Script of Copy String from column

Hello,

My DATA:

Code:
PLOKIJ1234G  12 13 14 15 
PLOKIJ1234E  12 13 14 15 
PLOKIJ1234F  12 22 33 44
IJNUHB12346  55 66 77 88
IJNUHB12347  32 34 45 67 
IJUHU345D  23 23 22 33
IJUHYG23E  11 24 23 23 
IJUHYG23F  77 88 99 00

output:

Code:
PLOKIJ1234 PLOKIJ1234G  12 13 14 15 
PLOKIJ1234 PLOKIJ1234E  12 13 14 15 
PLOKIJ1234 PLOKIJ1234F  12 22 33 44
IJNUHB1234 IJNUHB12346  55 66 77 88
IJNUHB1234 IJNUHB12347  32 34 45 67 
IJUHU343 IJUHU343D  23 23 22 33
IJUHYG23 IJUHYG23E  11 24 23 23 
IJUHYG23 IJUHYG23F  77 88 99 00

# 2  
Old 02-27-2012
Code:
$ nawk '{$1=$1" "$1;print}' input.txt
PLOKIJ1234G PLOKIJ1234G 12 13 14 15
PLOKIJ1234E PLOKIJ1234E 12 13 14 15
PLOKIJ1234F PLOKIJ1234F 12 22 33 44
IJNUHB12346 IJNUHB12346 55 66 77 88
IJNUHB12347 IJNUHB12347 32 34 45 67
IJUHU345D IJUHU345D 23 23 22 33
IJUHYG23E IJUHYG23E 11 24 23 23
IJUHYG23F IJUHYG23F 77 88 99 00

use awk, if you dont have nawk
# 3  
Old 02-27-2012
No Sir.. i dont want the last cher. form that column....
# 4  
Old 02-27-2012
# 5  
Old 02-27-2012
what you mean by last char ?

you dont want last column ?

something like this ?
Code:
 
 $ nawk '{$1=$1" "$1;$NF="";print}' test.txt
PLOKIJ1234G PLOKIJ1234G 12 13 14 
PLOKIJ1234E PLOKIJ1234E 12 13 14 
PLOKIJ1234F PLOKIJ1234F 12 22 33 
IJNUHB12346 IJNUHB12346 55 66 77 
IJNUHB12347 IJNUHB12347 32 34 45 
IJUHU345D IJUHU345D 23 23 22 
IJUHYG23E IJUHYG23E 11 24 23 
IJUHYG23F IJUHYG23F 77 88 99

# 6  
Old 02-27-2012
Code:
$ perl -lane '$x=$F[0]; $x=~s/\w$//; print "$x\t", join ("\t",@F)' inputfile
PLOKIJ1234      PLOKIJ1234G     12      13      14      15
PLOKIJ1234      PLOKIJ1234E     12      13      14      15
PLOKIJ1234      PLOKIJ1234F     12      22      33      44
IJNUHB1234      IJNUHB12346     55      66      77      88
IJNUHB1234      IJNUHB12347     32      34      45      67
IJUHU345        IJUHU345D       23      23      22      33
IJUHYG23        IJUHYG23E       11      24      23      23
IJUHYG23        IJUHYG23F       77      88      99      00

# 7  
Old 02-27-2012
Yes balajesuri .....That i want...Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to find string based on pattern and search for its corresponding rows in column

Experts, Need your support for this awk script. we have only one input file, all these column 1 and column 2 are in same file and have to do lookup for values in one file(column1 and column2) but output we need in another file Need to grep row whose string contains 9K from column 1. When found... (6 Replies)
Discussion started by: as7951
6 Replies

2. UNIX for Beginners Questions & Answers

How to copy a column of multiple files and paste into new excel file (next to column)?

I have data of an excel files as given below, file1 org1_1 1 1 2.5 100 org1_2 1 2 5.5 98 org1_3 1 3 7.2 88 file2 org2_1 1 1 2.5 100 org2_2 1 2 5.5 56 org2_3 1 3 7.2 70 I have multiple excel files as above shown. I have to copy column 1, column 4 and paste into a new excel file as... (26 Replies)
Discussion started by: dineshkumarsrk
26 Replies

3. Shell Programming and Scripting

Script to check and copy column entries

Hi I have a text file (INPUT.TXT) of three columns assuming they are separated by tab. The format is given as: Column1 Column2 Column3 aaa NO aaa bbb YES asdf ccc YES yyasdf ddd NO ddd eee ... (3 Replies)
Discussion started by: my_Perl
3 Replies

4. UNIX for Advanced & Expert Users

Copy a column to another column in UNIX fixedwidth file

Hi All, I have a fixedwidth file of length 3000. Now i want to copy a column of 4 chars i.e( length 1678-1681) to column 1127 – 1171 to the same file. Please let me know how can i achive using a single command in fixed width file. Also source column length is 4 chars and target column length... (4 Replies)
Discussion started by: kiranparsha
4 Replies

5. Shell Programming and Scripting

Copy column string and put in different column

Hello Here is my input: SU3902 SU3902A NS29C (10) (00) Q1J1 0 SU3902 SU3902B VLR05 (20) (02) Q2H1 4 SU3902 SU3902C NBR22 (30) (06) Q3R5 8 SU3904 SU39047 NSV19 (11) (09) Q4k6 2 SU3904 SU39048 LB231 (12) (05) Q5k1 6 SU3904 SU39049 11VLT (13) (08) Q10C1 10 SU3904 SU3904A 25R05 (15) (06)... (3 Replies)
Discussion started by: pareshkp
3 Replies

6. UNIX for Dummies Questions & Answers

Copy column to another column in unix

Dear Gurus, I have a unix file 2 columns (# delimited) with the following data: ZTXX_CTBR1-ZBRAN1#ZTXX_CTBR1-ZBRAN_DESC# 01#CASH & CARRY# 02#DRUGSTORE - RX# 04#SUPERMARKET# 05#HYPERMARKET# 17#DRUGSTORE - NO RX# I would like to have a code that will do 2 things: 1. Delete the header... (16 Replies)
Discussion started by: chumsky
16 Replies

7. Shell Programming and Scripting

input a string and copy lines from a file with that string on it

i have a file1 with many lines. i have a script that will let me input a string. for example, APPLE. what i need to do is to copy all lines from file1 where i can find APPLE or any string that i specify and paste in on file 2 thanks in advance! (4 Replies)
Discussion started by: engr.jay
4 Replies

8. Shell Programming and Scripting

Shell Script to Search for a particular String and copy the timestamp to a variable

Hi, We Perfrom Loads to the database through a Perl script which generates a statistics file. I need to read the statistics. the Statistics file looks something like below: Process Beginning - 08-26-2010-23.41.47 DB2 CONNECTION SUCCESSFUL! Ready to process and load file: FILENAME # of... (2 Replies)
Discussion started by: Praveenkulkarni
2 Replies

9. Shell Programming and Scripting

Copy the data column to adjacent column

Hi, i have file which contains only one record like below a|b|c|.... The no of columns is not known. The expected output is as below: a|a|b|b|c|c|... Please provide me your suggestions. OS: unix Thanks, Selva (7 Replies)
Discussion started by: bharathappriyan
7 Replies

10. UNIX for Advanced & Expert Users

extracting/copy a column into a new column

Hello, Anybody out there knows how to copy a column data into a blank column using unix command? Thanks (1 Reply)
Discussion started by: folashandy
1 Replies
Login or Register to Ask a Question