[Solved] Selective delete command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers [Solved] Selective delete command
# 1  
Old 11-08-2012
[Solved] Selective delete command

Hi All.
I didnt know how to put this question as but i want to delete my values following string_X but need to retain the data in it.
I hope the following might help me in conveying my doubt.
My sequence looks like this.
Code:
>string_1 CAJW010000001
WFGHHHHHHHHHHHWWWWWWWWQGGGGGGGGGGGGTTTTTTTTHYHYJUIKIKJNJNFDFDWAQAFTGYMNNNNNGQEEJEJEJEJEJRISISQLQLQLQQQQQFLFLFFOFOFOFOFOFF
>string_2 CAJW010000002
CCGCCGACCGCCCTCCCCCAACACGTAGGCCCCTTTCCCGAGCCTCTGCTTCATCTACACCATCGGTGACCCTCCGGGAGACACCCCCTTCCCACTTCCTCCCCCTCCGGCCACACTCCGGCCGCTGGCTGCACCTTGGCTCCGCCGCACGTCGCATCTGCCCGCTACGCTCCACAGCCA
>string _3 CAJW010000003 querm=1H
SDFEEEEEEEEEEEEEEEEEEEEEEEGTRTHHHKHHKHKHKHKQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQGGGGGGGGGGGGGGGGGGGGGGGGGGGGRIRIRRIRREEEE
 >string_4 CAJW010000005 querm=3HS
SADFRVGJYKFKFKKKIREIWOOQOOEOEOEOEOEVNTTIDISISPPVPBEWEQMSII

I want it to look like
Code:
>string_1 
WFGHHHHHHHHHHHWWWWWWWWQGGGGGGGGGGGGTTTTTTTTHYHYJUIKIKJNJNFDFDWAQAFTGYMNNNNNGQEEJEJEJEJEJRISISQLQLQLQQQQQFLFLFFOFOFOFOFOFF
>string_2 
CCGCCGACCGCCCTCCCCCAACACGTAGGCCCCTTTCCCGAGCCTCTGCTTCATCTACACCATCGGTGACCCTCCGGGAGACACCCCCTTCCCACTTCCTCCCCCTCCGGCCACACTCCGGCCGCTGGCTGCACCTTGGCTCCGCCGCACGTCGCATCTGCCCGCTACGCTCCACAGCCA
>string _3 
SDFEEEEEEEEEEEEEEEEEEEEEEEGTRTHHHKHHKHKHKHKQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQGGGGGGGGGGGGGGGGGGGGGGGGGGGGRIRIRRIRREEEE
 >string_4 
SADFRVGJYKFKFKKKIREIWOOQOOEOEOEOEOEVNTTIDISISPPVPBEWEQMSII

Moderator's Comments:
Mod Comment Please use code tags

I want to delete these values CAJW010000001,CAJW010000002 , CAJW010000003 querm=1H and so on but I want my next line to remain.
is this possible??
Thanks
Sonia

Last edited by jim mcnamara; 11-08-2012 at 10:44 PM..
# 2  
Old 11-08-2012
try this:

Code:
awk '/string/ {print $1; next} {print $0}'  inputfilename > outputfilename

This User Gave Thanks to jim mcnamara For This Post:
# 3  
Old 11-09-2012
Code:
awk '/string_/{$0=$1}1' input.txt > output.txt

This User Gave Thanks to itkamaraj For This Post:
# 4  
Old 11-09-2012
Thanks for commands !! It worked Smilie though I myself was unclear with my question!!
Thanks a lot!!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Selective replace and delete

Hi My input file looks like this: >BAHMI01000090.1 Details of the shopping list 9800 item00090, whole set of listed artifacts and objects >BAHMI01050012.1 Details of the shopping list 9800 item02310, whole set of listed artifacts and objects >BAHMI01070078.1 Details of the shopping list ... (5 Replies)
Discussion started by: sonia102
5 Replies

2. AIX

[Solved] Not able to delete/create file in /tmp

This is AIX box and I am not able to create or delete file in /tmp though space is there root@ttcols01/ #touch /tmp/test_file touch: 0652-046 Cannot create /tmp/test_file. root@ttcols01/ #mkdir /tmp/test_dir mkdir: 0653-358 Cannot create /tmp/test_dir. /tmp/test_dir: Invalid file system... (9 Replies)
Discussion started by: solaris_1977
9 Replies

3. UNIX for Dummies Questions & Answers

[Solved] Delete files older than 10 years

I need a command which delete files older than 10 years. I got a command for 90 days and all commands I find are for days and nothing for years. find file_name -mtime +90 -exec rm {} \; (5 Replies)
Discussion started by: eskay
5 Replies

4. UNIX for Dummies Questions & Answers

Selective delete in SQL

Hi All This might be a weird query but its related to deleting specific details in database. Bascially I had built a database using a set of files seq1 of 300 mb seq2 of 200 mb seq3 of 350 mb seq4 of 300 mb and after building the database i realized that i didn't need the whole data.... (6 Replies)
Discussion started by: sonia102
6 Replies

5. UNIX for Dummies Questions & Answers

[Solved] Weird files to delete

Hi, I created some files with a script and I don't know yet where I did a mistake but the script created some "weird" files... prd01,/tmp # ls -al total 706184 -rw-r----- 1 root system 34 Aug 27 16:10 hdisk3BB hdisk3 hdisk3BB.tmp drwxrwxrwt 51 bin bin ... (9 Replies)
Discussion started by: Castelior
9 Replies

6. Shell Programming and Scripting

Selective command line parameters.

Hi, I have a script which has 3 command line parameters.But sometimes it will also take 2 command line parameters or 1.How to do it? I am using $1,$2... to specify the command line parameters. The script which i have written is given below. #!/bin/sh echo "database="$1 echo... (3 Replies)
Discussion started by: arijitsaha
3 Replies

7. Shell Programming and Scripting

RegEx - selective delete around a pattern

I need RegEx to delete text block delimited by "^--" and "^request saved" if the block contained the pattern "FAILED:No air,rail,hotel or car" in the following. Many thanks in advance! company_id=9292 queue_id=72 internationalOnly=0 Building XML... ABC123 Adding passenger first=First ... (1 Reply)
Discussion started by: roshansharma
1 Replies

8. UNIX for Dummies Questions & Answers

[Solved] Delete files with condition

I have a directory containing thousands of items “video files”, these items were generated by an application, which generates two items with the same name but with different extensions “.avi and .mp4”. There was a tool in my application to remove one item @ a time. Later I found this tool removes... (5 Replies)
Discussion started by: awadeid
5 Replies

9. UNIX for Dummies Questions & Answers

[Solved] delete character in vi file

I have a file with lots of unnecessary double quotes ("). I tried to remove them but not successful. Please assist. Thanks! (3 Replies)
Discussion started by: onlinelearner02
3 Replies

10. UNIX Desktop Questions & Answers

Trying to delete a directory pattern-selective deletion

Trying to delete a directory or a file using a pattern-selective deletion (using “*” and “?” ) (4 Replies)
Discussion started by: herberwz
4 Replies
Login or Register to Ask a Question