Visit Our UNIX and Linux User Community


Checking subset and removing extra letters


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Checking subset and removing extra letters
# 1  
Old 02-21-2013
Checking subset and removing extra letters

In each line of file, I wish to check if word1 is a non-connected subset of any of the other words in the line. If yes, keep only the words that ward1 is a subset of. Else, remove the whole line.
Also, I want to remove the letters that word1 doesn't match with, except for "_+"

Example file:
Code:
abcde  abc_+hde   ab_+ce_+de
higk    h_+al_+gk 
xyz     a_+xyz      axy_+s

Desired output:
Code:
abcde  abc_+de     ab_+c_+de
xyz     xyz


Last edited by vbe; 02-21-2013 at 08:53 AM.. Reason: code tags please for data also...
# 2  
Old 02-21-2013
I do not understand what you like to do.
Post real life example with many lines, and desired output.
# 3  
Old 02-21-2013
Here's a real life example, a very short snippet:
Input:
Code:
AlA$AEAt  Al_+A$AE_+At_+i  Al_+A$AE_+At_+i  Al_+<i$AE_+At_+u Al_+<i$AE_+At
AlA$AEAt Al_+<i*AE_+At_+i  Al_+<i*AE_+At_+u Al_+<i*AE_+At_+i Al_+<i*AE_+At
A*AbthA A*Ab_+at_+hA iA*Ab_+at_+a_+hA <i*Ab_+at_+i_+hA A*Ab_+at_+u_+hA

Desired output:
Code:
AlA$AEAt  Al_+A$AE_+At  Al_+A$AE_+At   
A*AbthA A*Ab_+t_+hA A*Ab_+t_+_+hA A*Ab_+t_+hA


Last edited by Franklin52; 02-21-2013 at 11:04 AM.. Reason: Code tags

Previous Thread | Next Thread
Test Your Knowledge in Computers #569
Difficulty: Medium
foreach loops are considered syntactic sugar.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Removing letters after a certain character within a range of columns

Hi there, I am trying to remove al letters after : character on specific columns from 10th column till 827. I used sed and cut to do so but I am sure there is better one liner someone can think of from unix community members. Huge file but it has this structure (Total number of Columns =... (10 Replies)
Discussion started by: daashti
10 Replies

2. Shell Programming and Scripting

Removing extra lines from file

I have a file where data looks like this: === <?xml version="1.0" encoding="utf-8"?> <xml xmlns:s='uuid:XYZ' xmlns:dt='uuid:ABC' xmlns:rs='urn:schemas-microsoft-com:rowset' xmlns:z='#RowsetSchema'> <s:Schema id='RowsetSchema'> <s:ElementType name='row'... (7 Replies)
Discussion started by: vx04
7 Replies

3. Shell Programming and Scripting

Removing extra unwanted spaces

hi, i need to remove the extra spaces in the 2nd field. Sample: abc|bd |bkd123 .. 1space abc|badf |bakdsf123 .. 2space abc|bqe |bakuowe .. 3space Output: abc|bd|bkd123 abc|badf|bakdsf123 abc|bqe|bakuowe i used the following command, (9 Replies)
Discussion started by: anshaa
9 Replies

4. Shell Programming and Scripting

Removing extra unwanted spaces

hi, i need to remove the extra spaces in the filed. Sample: abc~bd ~bkd123 .. 1space abc~badf ~bakdsf123 .. 2space abc~bqed ~bakuowe .. 3space output: abc~bd ~bkd123 .. 1space abc~badf~bakdsf123 .. 2space abc~bqed~bakuowe .. 3space i used the following command, (2 Replies)
Discussion started by: anshaa
2 Replies

5. UNIX for Dummies Questions & Answers

Removing Extra Folders From a TAR

I use an extremely simple TAR function for files at work and I have a question about cleaning them up. My command is TAR -cvf ExampleTarName.tar then the folder I wish to TAR. When my TAR finishes and I double click it to check it unarchived beautifully (I don't do this with every file, duh)... (5 Replies)
Discussion started by: Dogtown24
5 Replies

6. UNIX for Dummies Questions & Answers

Removing extra new line characters

Hello, I have a text file that looks like: ABC123|some text|some more text|00001 00002 0003 0004 000019|000003|Item I have searched and found an example to remove the extra new line characters using grep and sed, but it (I think) assumes the lines start with a number and the... (5 Replies)
Discussion started by: c56444
5 Replies

7. UNIX for Dummies Questions & Answers

Help with Removing extra characters in Filename

Hi, It's my first time here... anyways, I have a simple problem with these filenames. This is probably too easy for you guys: ABC_20101.2A.2010_01 ABD_20103.2E.2010_04 ABE_20107.2R.2010_08 Expected Output: ABC_20101 ABD_20103 ABE_20107 The only pattern available are the ff: 1) All... (9 Replies)
Discussion started by: Joule
9 Replies

8. Shell Programming and Scripting

removing extra files in dos

Hi, I have same file by name i want to keep only access file and want to delete rest. This is specific to DOS only. Any idea of doing this. I tried so many options but none worked for me. Thanks Namish (11 Replies)
Discussion started by: namishtiwari
11 Replies

9. UNIX for Dummies Questions & Answers

checking wether an input is using letters of the alphabet

afternoon forums. I need to get a way of testing as to wether an inputed character is part of the english alphabet. i have come up with the following code but its not working at all. until '] do echo This is not a Letter done any help would be beneficial to me. (1 Reply)
Discussion started by: strasner
1 Replies

10. Shell Programming and Scripting

Removing Letters from Integer String

Hi all, I have a variable, on some machines it is '1024', which is fine, but on others it is '1024Mb' etc. I need this variable to simply be '1024', does anyone know how I could ensure this is always the case? Perhaps a command to remove any letters/characters that aren't integers if there is... (3 Replies)
Discussion started by: hodges
3 Replies

Featured Tech Videos