Sponsored Content
Top Forums Shell Programming and Scripting sed copy column value add to certain area Post 302367897 by frans on Tuesday 3rd of November 2009 05:55:49 PM
Old 11-03-2009
That works with your sample data
Code:
# IMPORTANT : we assume that the input file is sorted
function Output () { echo "${BASE} ${SP:-0000000}XXX${CH:-0000000}" ; }
{    while read LINE
     do
          #~ echo ${LINE:27:6}
          if [ "${LINE:27:3}" = "OLF" ]
          then
               [ -n "$BASE" ] && Output
               BASE="${LINE}XXX"; SP=""; CH=""
          fi
          [ "${LINE:27:6}" = "ODL-SP" ] && SP=${LINE:10:7}
          [ "${LINE:27:6}" = "ODL-CH" ] && CH=${LINE:10:7}
     done < FILE1.dat
     Output
} > FILE2.dat

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SED remove line feed and add to certain area

Hi All, I have a xml file and requirement is to remove the line feed and add line feed after some element. <?xml version="1.0" ?> <AUDITRECORDS> <CARF> <HED> <VN1>20090616010622</VN1> <VN2>0</VN2> <VN3>1090</VN3> <VN4>CONFIG_DATA</VN4> ... (8 Replies)
Discussion started by: sreejitnair123
8 Replies

2. UNIX for Advanced & Expert Users

Compare two files using awk or sed, add values in a column if their previous fields are same

Hi All, I have two files file1: abc,def,ghi,5,jkl,mno pqr,stu,ghi,10,vwx,xyz cba,ust,ihg,4,cdu,oqw file2: ravi,def,kishore ramu,ust,krishna joseph,stu,mike I need two output files as follows In my above example, each row in file1 has 6 fields and each row in file2 has 3... (1 Reply)
Discussion started by: yerruhari
1 Replies

3. UNIX for Dummies Questions & Answers

Compare two files using awk or sed, add values in a column if their previous fields are same

Hi All, I have two files file1: abc,def,ghi,5,jkl,mno pqr,stu,ghi,10,vwx,xyz cba,ust,ihg,4,cdu,oqw file2: ravi,def,kishore ramu,ust,krishna joseph,stu,mike I need two output files as follows In my above example, each row in file1 has 6 fields and each row in file2 has 3... (1 Reply)
Discussion started by: yerruhari
1 Replies

4. Shell Programming and Scripting

Compare two files using awk or sed, add values in a column if their previous fields are same

Hi All, I have two files file1: abc,def,ghi,5,jkl,mno pqr,stu,ghi,10,vwx,xyz cba,ust,ihg,4,cdu,oqw file2: ravi,def,kishore ramu,ust,krishna joseph,stu,mike I need two output files as follows In my above example, each row in file1 has 6 fields and each row in file2 has 3... (3 Replies)
Discussion started by: yerruhari
3 Replies

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

6. Shell Programming and Scripting

Need to add letters to a column and add in a new column subtracting from another column

So I have this input 1 10327 rs112750067 T C . PASS DP=65;AF=0.208;CB=BC,NCBI 1 10469 rs117577454 C G . PASS DP=2055;AF=0.020;CB=UM,BC,NCBI 1 10492 rs55998931 C T . PASS DP=231;AF=0.167;CB=BC,NCBI 1 10583 rs58108140 G A ... (3 Replies)
Discussion started by: kellywilliams
3 Replies

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

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

9. Shell Programming and Scripting

sed command to add a new column entry

My input file looks like this 12 3 5.122.281.413 172.31.15.220 3421 4133 2 2 1454 3421 4133 2 2 0 12 44036 214.215.52.146 90.123.245.211 2312 3911 4 4 521 2312 3911 4 4 1 14 504 6.254.324.219 192.61.27.120 4444 5611 7 5 1415 4444 5611 7 5 1 ... (2 Replies)
Discussion started by: sampitosh
2 Replies

10. 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
ZILE(1) 							   User Commands							   ZILE(1)

NAME
Zile - Zile Is Lossy Emacs SYNOPSIS
zile [OPTION-OR-FILENAME]... DESCRIPTION
Zile is a lightweight Emacs clone that provides a subset of Emacs's functionality suitable for basic editing. Run Zile, the lightweight Emacs clone. Initialization options: --no-init-file, -q do not load ~/.zile --funcall, -f FUNC call Zile Lisp function FUNC with no arguments --load, -l FILE load Zile Lisp FILE using the load function --help display this help message and exit --version display version information and exit Action options: FILE visit FILE using find-file +LINE FILE visit FILE using find-file, then go to line LINE Exit status is 0 if OK, 1 if it cannot start up, for example because of an invalid command-line argument, and 2 if it crashes or runs out of memory. FILES
~/.zile -- user's Zile init file /usr/share/zile/dotzile-extra.el -- which contains some useful code for the init file. AUTHOR
Zile was written by Sandro Sigala, David A. Capello and Reuben Thomas. The Lisp interpreter is based on code by Scott Lawrence. REPORTING BUGS
Report bugs to bug-zile@gnu.org. COPYRIGHT
Copyright (C) 2010 Free Software Foundation, Inc. GNU Zile comes with ABSOLUTELY NO WARRANTY. You may redistribute copies of Zile under the terms of the GNU General Public License. For more information about these matters, see the file named COPYING. SEE ALSO
emacs(1) Zile 2.3.20 November 2010 ZILE(1)
All times are GMT -4. The time now is 03:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy