[Solved] eliminate characters in vi


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers [Solved] eliminate characters in vi
# 1  
Old 09-27-2012
[Solved] eliminate characters in vi

hey guys. what command in vi editor should I write to make


this
Code:
M83RDK-078A        -1        1     1024        1     1024 OK           X     |
M83RDK-055         -1        1      627        1      627 OK           X     |

become like this
Code:
M83RDK-078A   1     1024
M83RDK-055     1      627

thx

Moderator's Comments:
Mod Comment Please use code tags next time for your code and data.

Last edited by vbe; 09-27-2012 at 05:01 AM..
# 2  
Old 09-27-2012
Code:
:1,$s/\([^ \t]*\)[ \t]*[^ \t]*[ \t]*\([^ \t]*\)[ \t]*\([^ \t]*\).*/\1   \2   \3/

# 3  
Old 09-30-2012
Quote:
Originally Posted by rdrtx1
Code:
:1,$s/\([^ \t]*\)[ \t]*[^ \t]*[ \t]*\([^ \t]*\)[ \t]*\([^ \t]*\).*/\1   \2   \3/

thx. it works.
# 4  
Old 10-04-2012
what about the command to transform

Code:
S07TWN-019          -1        1     1084     1943     3026 OK           X     |
S07TWN-014          -1        1     1084     1943     3026 OK           X     |

become like this

Code:
S07TWN-019    1943     3026
S07TWN-014    1943     3026

# 5  
Old 10-04-2012
Code:
:1,$s/\([^ \t]*\)[ \t]*\([^ \t]*\)[ \t]*\([^ \t]*\)[ \t]*\([^ \t]*\)[ \t]*\([^ \t]*\)[ \t]*\([^ \t]*\).*/\1   \5   \6/

# 6  
Old 10-11-2012
Quote:
Originally Posted by rdrtx1
Code:
:1,$s/\([^ \t]*\)[ \t]*\([^ \t]*\)[ \t]*\([^ \t]*\)[ \t]*\([^ \t]*\)[ \t]*\([^ \t]*\)[ \t]*\([^ \t]*\).*/\1   \5   \6/


thx it works
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] Count characters of variable from right

My variable is something like: f="/Volumes/VERVE/MOOTON_CALL/01_shots/XX/xx0195/Projects/program/rs0195_v400001.aep" I use ${f:63:6} to call "rs0195" as characters counted from the left, but it'd be so much easier to count from the right. If ${f:95:10} counts from the left, what would... (2 Replies)
Discussion started by: scribling
2 Replies

2. Shell Programming and Scripting

[Solved] How to separate one line to mutiple line based on certain number of characters?

hi Gurus, I need separate a file which is one huge line to multiple lines based on certain number of charactors. for example: abcdefghi high abaddffdd I want to separate the line to multiple lines for every 4 charactors. the result should be abcd efgh i hi gh a badd ffdd Thanks in... (5 Replies)
Discussion started by: ken6503
5 Replies

3. Shell Programming and Scripting

Need help to eliminate the records

Hi All, Please help me how to remove the records from the file if it is having more number of fields than the required one, before loading into stage Here is the sample records. File is space delimited one chandu 1121324 CC ( 2 spaces) chandu balu 434657 DD (3 spaces) -- failing due to... (10 Replies)
Discussion started by: bbc17484
10 Replies

4. UNIX for Dummies Questions & Answers

[Solved] Listing files starting with p or f and with the exact length of 3 characters

Hello, I need some help. How can I list files starting with p or f and with the exact length of 3 characters? (2 Replies)
Discussion started by: airbebe
2 Replies

5. UNIX for Dummies Questions & Answers

[Solved] How to search for these escape characters?

echo "***Enter new LISTENER_PORT (only applicable to new instance), " I used the following: E486: Pattern not found: echo \"\*\*\*Enter new LISTENER_PORT \(only applicable to new instanace\), \" when I try to search for the above line, I'm not able to do it so how do I search for the... (5 Replies)
Discussion started by: jediwannabe
5 Replies

6. UNIX for Dummies Questions & Answers

[Solved] Removing control-m characters from shell script

Hi All, I need to remove control m character from a file. Steps which i am doing in shell script are: 1) We are comparing the header of the file to the database table header Here the file header has control-m characters. How do i remove it. Please help. Below are the steps i am using,... (12 Replies)
Discussion started by: abhi_123
12 Replies

7. UNIX for Dummies Questions & Answers

[solved]removing characters from a mass of file names

I found a closed thread that helped quite a bit. I tried adding the URL, but I can't because I don't have enough points... ? Modifying the syntax to remove ! ~ find . -type f -name '*~\!]*' | while IFS= read -r; do mv -- "$REPLY" "${REPLY//~\!]}"; done These messages are... (2 Replies)
Discussion started by: rabidphilbrick
2 Replies

8. Shell Programming and Scripting

[Solved] Counting specific characters within each field

Hello, I have a file like following: ALB_13554 1 1 1 ALB_13554 1 2 1 ALB_18544 2 0 2 ALB_18544 1 0 1 This is a sample of my file, my real file has 441845 number of fields. What I want to do is to calculate the number of 1 and 2 in each column using AWK, so, the output file looks like... (5 Replies)
Discussion started by: Homa
5 Replies

9. UNIX for Dummies Questions & Answers

[Solved] Extracting all characters from a string

I want to extract the string TC from the string TC10, the string can have any characters out of . I used the following code but didnt get the right output. Please guide nuc=match(val,/*/) seq=substr(val,RSTART,RLENGTH) ---------- Post updated at 09:40 PM ---------- Previous update was... (0 Replies)
Discussion started by: newbie83
0 Replies

10. Shell Programming and Scripting

How to eliminate ^L

Hi, I am trying to create a text file from data retrieved from a query.The data retrieved is having this character '^L' at regular intervals of the data. How can i eliminate this, Please find below the sample data. I tried sed -e "s/\^L//g" to convert it, but with no luck ^LCODE*SERIAL... (11 Replies)
Discussion started by: ramkiran77
11 Replies
Login or Register to Ask a Question