Visit Our UNIX and Linux User Community


How to manipulate first column and reverse the line order in third and fourth column?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to manipulate first column and reverse the line order in third and fourth column?
# 1  
Old 07-30-2009
How to manipulate first column and reverse the line order in third and fourth column?

How to manipulate first column and reverse the line order in third and fourth column as follws?

For example i have a original file like this:

file1
Code:
     0.00000000E+000    -1.17555359E-001     0.00000000E+000
     2.00000000E-002    -1.17555359E-001     0.00000000E+000
     4.00000000E-002    -1.17639683E-001     0.00000000E+000
     6.00000000E-002    -1.17655106E-001     0.00000000E+000
     8.00000000E-002    -1.17603991E-001     0.00000000E+000
     1.00000000E-001    -1.17488978E-001     0.00000000E+000

I want to
-manipulate first column
-reverse the line order in third and fourth column (I can already do that:
https://www.unix.com/shell-programming-scripting/35832-reversing-order-lines-file-4.html
)
-remove last line.

-->file2:
Code:
     1.20000000E-001    -1.17603991E-001     0.00000000E+000
     1.40000000E-001    -1.17655106E-001     0.00000000E+000
     1.60000000E-001    -1.17639683E-001     0.00000000E+000
     1.80000000E-001    -1.17555359E-001     0.00000000E+000
     2.00000000E-001    -1.17555359E-001     0.00000000E+000

Finally I 'm going to merge these files.

---------- Post updated 30-07-09 at 11:13 AM ---------- Previous update was 29-07-09 at 05:08 PM ----------

What I wanted most was to know this:
Quote:
Originally Posted by Max Well
I want to
-manipulate first column
Other questions are extra.
# 2  
Old 07-30-2009
Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Proceed here:

https://www.unix.com/shell-programmin...#post302339299

Thank You.

The UNIX and Linux Forums.

Previous Thread | Next Thread
Test Your Knowledge in Computers #185
Difficulty: Medium
Moderating questions and answers at UNIX.com requires superior UNIX shell scripting abilities.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] Extract First character in fourth column

Hi Experts, I am new to UNIX. One of my file records are like below 220 IN C/A 515013 NULL NULL 220 IN C/A 515017 NULL NULL 225 IN C/A 333701 NULL NULL 225 IN C/A 515034 NULL NULL 225 IN C/A 499201 NULL NULL 225 IN C/A 499202 NULL NULL The above mentioned records delimiter is... (4 Replies)
Discussion started by: suresh_target
4 Replies

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

3. Shell Programming and Scripting

Manipulate XML File Continous STRING by each Order Line using SHELL

heres sample File: <?xml version="1.0"?> <!DOCTYPE cXML SYSTEM "www"><cXML.............................................. <OrderRequest>USE UNIX.com</Extrinsic><Extrinsic name="UniqueName">Peter@UNIX.com</Extrinsic><Extrinsic name="ContractingEntity">UNIX... (3 Replies)
Discussion started by: Pete.kriya
3 Replies

4. Shell Programming and Scripting

replace by match on fourth column

Hi friends, My input file is this way chr1 100 200 "abc" chr1 350 400 "abc" chr2 450 600 "def" chr2 612 780 "def" How do I make this file into chr1 100 400 "abc" chr2 450 780 "def" This is basically matching on the fourth column and taking the minimum of second column and the... (4 Replies)
Discussion started by: jacobs.smith
4 Replies

5. Shell Programming and Scripting

1st column,2nd column on first line 3rd,4th on second line ect...

I need to take one column of data and put it into the following format: 1st line,2nd line 3rd line,4th line 5th line,6th line ... Thanks! (6 Replies)
Discussion started by: batcho
6 Replies

6. Shell Programming and Scripting

comparing column of two different files and print the column from in order of 2nd file

Hi friends, My file is like: Second file is : I need to print the rows present in file one, but in order present in second file....I used while read gh;do awk ' $1=="' $gh'" {print >> FILENAME"output"} ' cat listoffirstfile done < secondfile but the output I am... (14 Replies)
Discussion started by: CAch
14 Replies

7. Shell Programming and Scripting

Print rows in reverse order if values decrease along the column

Hi, Guys. Please help me to find solution to this problem using shell scripting. I have an INPUT file with 4 columns separated by tab. Each block of records is separated by ----- ----- Sample1 5402 6680 Pattern01 Sample2 2216 2368 Pattern02... (6 Replies)
Discussion started by: sam_2921
6 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

Conditional reverse of certain file line order

Hi I am brand new to programming, I dont know how to go about this task, or what language is best for this...If there is an easy solution in different languages, I would love to see them. I want to learn about the steps to take on this, so Please put in comments where code is used. I believe in... (9 Replies)
Discussion started by: perlrookie
9 Replies

10. Shell Programming and Scripting

read line in reverse order from file

dear all i want to read 5th no of line from last line of file. kindly suggest me possible ways. rgds jaydeep (2 Replies)
Discussion started by: jaydeep_sadaria
2 Replies

Featured Tech Videos