Removing all characters on and before specific point


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Removing all characters on and before specific point
# 1  
Old 11-10-2008
Removing all characters on and before specific point

Im having a file with records

DB1635 |Y|N|DB1632 |000024968_202 |0|000024968302|RCF02|
DB1636 |Y|N|DB1633 |000024968_203 |0|000024968302|RCF02|

i want to get output as

Y|DB1632 |RCF02|
Y|DB1633 |RCF02|

how can i do this ?? any help ???
# 2  
Old 11-10-2008
Code:
awk -F"|" '{print $2 FS $4 FS $8 FS}' file

Regards
# 3  
Old 11-10-2008
Using cut

cat filename | cut -d"|" -f 2,4,8
# 4  
Old 11-10-2008
Quote:
Originally Posted by psspin
cat filename | cut -d"|" -f 2,4,8
easier would be "cut -d"|" -f 2,4,8 filename".
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Possible to insert a few lines of code into a file at a specific point?

Hi Folks - How would I go about inserting a chunk of lines (3) into a specific portion of a file? The background is I have a script (non shell) that it executed daily, however on Sundays, I uncomment a section of code so that piece can be run as well. So I was hoping to write a piece of... (9 Replies)
Discussion started by: SIMMS7400
9 Replies

2. Shell Programming and Scripting

Help with Round Up with 2 decimal point at specific column

Input file: USA 20.5683 UK 3.54221 Japan 2.54001 China 2.50897 Germany 2.05816 . . Desired output file: USA 20.57 UK 3.54 Japan 2.54 China 2.51 Germany 2.06 . . (2 Replies)
Discussion started by: perl_beginner
2 Replies

3. Shell Programming and Scripting

Isolate first characters until specified point

Hi everyone, I am in a pickle. I need to isolate an element of each line. I have data that looks like this: about+n+n-talk-n about+ns+ns-talk-n about+ns+n-talk-n about+ns+v-say-v as+n-a-j+vp-look-v as+ns+v-come-v as+ns+vn-list-v and I need to isolate all the characterts until the... (6 Replies)
Discussion started by: owwow14
6 Replies

4. Shell Programming and Scripting

Count specific characters at specific column positions

Hi all, I need help. I have an input text file (input.txt) like this: 21 GTGCAACACCGTCTTGAGAGG 50 21 GACCGAGACAGAATGAAAATC 73 21 CGGGTCTGTAGTAGCAAACGC 108 21 CGAAAAATGAACCCCTTTATC 220 21 CGTGATCCTGTTGAAGGGTCG 259 Now I need to count A/T/G/C numbers at each character location in column... (2 Replies)
Discussion started by: thienxho
2 Replies

5. Shell Programming and Scripting

Can't figure out how to find specific characters in specific columns

I am trying to find a specific set of characters in a long file. I only want to find the characters in column 265 for 4 bytes. Is there a search for that? I tried cut but couldn't get it to work. Ex. I want to find '9999' in column 265 for 4 bytes. If it is in there, I want it to print... (12 Replies)
Discussion started by: Drenhead
12 Replies

6. UNIX for Dummies Questions & Answers

Join Lines at a specific point

Hi I'm a beginner, and i've been having trouble joining two lines. I need to convert this file 1097ALABAMA Mobile County METHOMYL INSE CTICIDES 6 1.6200000E+00 1.8000001E+00 1003ALABAMA Baldwin County ... (5 Replies)
Discussion started by: kf_1434
5 Replies

7. Shell Programming and Scripting

sed replacing specific characters and control characters by escaping

sed -e "s// /g" old.txt > new.txt While I do know some control characters need to be escaped, can normal characters also be escaped and still work the same way? Basically I do not know all control characters that have a special meaning, for example, ?, ., % have a meaning and have to be escaped... (11 Replies)
Discussion started by: ijustneeda
11 Replies

8. Shell Programming and Scripting

Html parsing - get line after specific string till a point

Hi all :) It sounds complex, for example I want to find the whole html file (there are 5 entries of this string and I need to get all of them) for the string "<td class="contentheading" width="100%">", get the next line from it only till the point that says "</td>", plus removing \t (tabs) ... (6 Replies)
Discussion started by: hakermania
6 Replies

9. Shell Programming and Scripting

Bash take word after specific point and till next space?

Hello, I have an output like Interface Chipset Driver wlan0 Intel 4965/5xxx iwlagn - and I want to take only the 'wlan0' string. This can be done by a="Interface Chipset Driver wlan0 Intel 4965/5xxx iwlagn - " b=${a:25:6} echo $bThe thing is that wlan0 can be something else, like eth0 or... (2 Replies)
Discussion started by: hakermania
2 Replies

10. Shell Programming and Scripting

Test to see if a drive is mounted at a specific point

I have a script that backs up our storage drive daily to one external drive and weekly to another. What I'd like to do is find a way, in the script, to test whether the drives are mounted so that it doesn't accidentally fill up the main drive in the event of a drive failure, etc. Any ideas on how... (1 Reply)
Discussion started by: spectre_240sx
1 Replies
Login or Register to Ask a Question