Sponsored Content
Top Forums Shell Programming and Scripting How to delete strings in a file? Post 302906932 by the_simpsons on Tuesday 24th of June 2014 03:37:57 PM
Old 06-24-2014
How to delete strings in a file?

hi, i have a big file like this:
Code:
>s31 length=12 numreads=6 gene=isotig454 status=igo
ldfddfdfdfdkkkkkkfdfdkkkksdfdkkkkkkkkkksdfd
dfdfdfldfdkdffdlfddflfdjkkkkkkfdgkkgfhghfgkkk
ldfddfdfdfdkkkkkkfdfdkkkksdfdkkkkkkkkkksdfd
dfdfdfldfdkdffdlfddflfdjkkkkkkfdgkkgfhghfgkkk

>c2 length =344 numreads=4 gene=isotig343 status=igoere
ldfddfdfdfdkkkkkkfdfdkkkksdfdkkkkkkkkkksdfd
dfdfdfldfdkdffdlfddflfdjkkkkkkfdgkkgfhghfgkkk
ldfddfdfdfdkkkkkkfdfdkkkksdfdkkkkkkkkkksdfd
dfdfdfldfdkdffdlfddflfdjkkkkkkfdgkkgfhghfgkkk
ldfddfdfdfdkkkkkkfdfdkkkksdfdkkkkkkkkkksdfd
dfdfdfldfdkdffdlfddflfdjkkkkkkfdgkkgfhghfgkkk
ldfddfdfdfdkkkkkkfdfdkkkksdfdkkkkkkkkkksdfd
dfdfdfldfdkdffdlfddflfdjkkkkkkfdgkkgfhghfgkkk

>age3 length =32 
ldfddfdfdfdkkkkkkfdfdkkkksdfdkkkkkkkkkksdfd
dfdfdfldfdkdffdlfddflfdjkkkkkkfdgkkgfhghfgkkk
ldfddfdfdfdkkkkkkfdfdkkkksdfdkkkkkkkkkksdfd
dfdfdfldfdkdffdlfddflfdjkkkkkkfdgkkgfhghfgkkk
ldfddfdfdfdkkkkkkfdfdkkkksdfdkkkkkkkkkksdfd

.....

for each line with ">", i only want to keep the > and the name, like this:

Code:
>s31 
ldfddfdfdfdkkkkkkfdfdkkkksdfdkkkkkkkkkksdfd
dfdfdfldfdkdffdlfddflfdjkkkkkkfdgkkgfhghfgkkk
ldfddfdfdfdkkkkkkfdfdkkkksdfdkkkkkkkkkksdfd
dfdfdfldfdkdffdlfddflfdjkkkkkkfdgkkgfhghfgkkk

>c2 
ldfddfdfdfdkkkkkkfdfdkkkksdfdkkkkkkkkkksdfd
dfdfdfldfdkdffdlfddflfdjkkkkkkfdgkkgfhghfgkkk
ldfddfdfdfdkkkkkkfdfdkkkksdfdkkkkkkkkkksdfd
dfdfdfldfdkdffdlfddflfdjkkkkkkfdgkkgfhghfgkkk
ldfddfdfdfdkkkkkkfdfdkkkksdfdkkkkkkkkkksdfd
dfdfdfldfdkdffdlfddflfdjkkkkkkfdgkkgfhghfgkkk
ldfddfdfdfdkkkkkkfdfdkkkksdfdkkkkkkkkkksdfd
dfdfdfldfdkdffdlfddflfdjkkkkkkfdgkkgfhghfgkkk

>age3
ldfddfdfdfdkkkkkkfdfdkkkksdfdkkkkkkkkkksdfd
dfdfdfldfdkdffdlfddflfdjkkkkkkfdgkkgfhghfgkkk
ldfddfdfdfdkkkkkkfdfdkkkksdfdkkkkkkkkkksdfd
dfdfdfldfdkdffdlfddflfdjkkkkkkfdgkkgfhghfgkkk
ldfddfdfdfdkkkkkkfdfdkkkksdfdkkkkkkkkkksdfd

.....

how could i obtain this?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete strings in a file

Hi, I have a file named status.txt that looks like the file below. What I want to do is to delete the part <status> and </status> and just leave the number and print each number per line. How can I do it? If I will use sed or awk how can I do it? I tried with sed but it didn't work. Maybe I... (8 Replies)
Discussion started by: ayhanne
8 Replies

2. Shell Programming and Scripting

recursively delete the text between 2 strings from a file

i have 200000bytes size of a unix file i need to delete some text between two strings recursively using a loop with sed or awk . these two strings are : 1st string getting from a file :::2 nd string is fi...its constant . can anyone help me sed -n'/<1 st string >/,/fi/' <input_filename> is the... (2 Replies)
Discussion started by: santosh1234
2 Replies

3. Shell Programming and Scripting

Delete Strings that are present in another file

HI, if a String is present in file1.txt, i want to delete that String from file2.txt. How can i do this?? I am sure that the file1.txt is a subset of file2.txt. (2 Replies)
Discussion started by: jathin12
2 Replies

4. UNIX for Dummies Questions & Answers

Delete strings in file1 based on the list of strings in file2

Hello guys, should be a very easy questn for you: I need to delete strings in file1 based on the list of strings in file2. like file2: word1_word2_ word3_word5_ word3_word4_ word6_word7_ file1: word1_word2_otherwords..,word3_word5_others... (7 Replies)
Discussion started by: roussine
7 Replies

5. Shell Programming and Scripting

Delete lines in file containing duplicate strings, keeping longer strings

The question is not as simple as the title... I have a file, it looks like this <string name="string1">RZ-LED</string> <string name="string2">2.0</string> <string name="string2">Version 2.0</string> <string name="string3">BP</string> I would like to check for duplicate entries of... (11 Replies)
Discussion started by: raidzero
11 Replies

6. Shell Programming and Scripting

Delete chunk of text if contains certain strings

Using awk how to delete chunk of text if it contains certain strings? As in the following, delete a reference chunk, i.e. everything from <reference attribute = "value"> to </reference> inclusive, if within it "Group ID" value is 7 or 96 or 103 or 1005. <reference attribute = "value"> ... (3 Replies)
Discussion started by: pioavi
3 Replies

7. Shell Programming and Scripting

Delete 2 strings from 1 line with sed?

Hi guys, I wonder if it's possible to search for a line containing 2 strings and delete that line and perhaps replace the source file with already deleted line(s). What I mean is something like this: sourcefile.txt line1: something 122344 somethin2 24334 45554676 line2: another something... (6 Replies)
Discussion started by: netrom
6 Replies

8. Shell Programming and Scripting

Delete lines starting with these strings

Platform : RHEL 5.8 I have text file called myapplication.log . In this file, I have around 800 lines which start with the followng three strings PWRBRKER-3493 PWRBRKER-7834 SCHEDULER-ERROR How can I delete these lines in one go ? (13 Replies)
Discussion started by: omega3
13 Replies

9. UNIX for Dummies Questions & Answers

Delete specific strings in a file

Hi, My file has a numerous sttrings.I want to retain those strings which start with stt and delete entries with >C For eg: my infile is >C4603985... (7 Replies)
Discussion started by: sa@@
7 Replies

10. UNIX for Beginners Questions & Answers

Use strings from nth field from one file to match strings in entire line in another file, awk

I cannot seem to get what should be a simple awk one-liner to work correctly and cannot figure out why. I would like to use patterns from a specific field in one file as regex to search for matching strings in the entire line ($0) of another file. I would like to output the lines of File2 which... (1 Reply)
Discussion started by: jvoot
1 Replies
Locale::Codes::LangExt(3pm)				 Perl Programmers Reference Guide			       Locale::Codes::LangExt(3pm)

NAME
Locale::Codes::LangExt - standard codes for language extension identification SYNOPSIS
use Locale::Codes::LangExt; $lext = code2langext('acm'); # $lext gets 'Mesopotamian Arabic' $code = langext2code('Mesopotamian Arabic'); # $code gets 'acm' @codes = all_langext_codes(); @names = all_langext_names(); DESCRIPTION
The "Locale::Codes::LangExt" module provides access to standard codes used for identifying language extensions, such as those as defined in the IANA language registry. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default IANA language registry codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language extensions. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $lext = code2langext('acm','alpha'); $lext = code2langext('acm',LOCALE_LANGEXT_ALPHA); The codesets currently supported are: alpha This is the set of three-letter (lowercase) codes from the IANA language registry, such as 'acm' for Mesopotamian Arabic. This is the default code set. ROUTINES
code2langext ( CODE [,CODESET] ) langext2code ( NAME [,CODESET] ) langext_code2code ( CODE ,CODESET ,CODESET2 ) all_langext_codes ( [CODESET] ) all_langext_names ( [CODESET] ) Locale::Codes::LangExt::rename_langext ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangExt::add_langext ( CODE ,NAME [,CODESET] ) Locale::Codes::LangExt::delete_langext ( CODE [,CODESET] ) Locale::Codes::LangExt::add_langext_alias ( NAME ,NEW_NAME ) Locale::Codes::LangExt::delete_langext_alias ( NAME ) Locale::Codes::LangExt::rename_langext_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangExt::add_langext_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangExt::delete_langext_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. http://www.iana.org/assignments/language-subtag-registry The IANA language subtag registry. AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 2011-2013 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.18.2 2013-11-04 Locale::Codes::LangExt(3pm)
All times are GMT -4. The time now is 09:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy