Sponsored Content
Top Forums Shell Programming and Scripting Delete lines in file containing duplicate strings, keeping longer strings Post 302556116 by raidzero on Friday 16th of September 2011 04:07:13 PM
Old 09-16-2011
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

Code:
<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 string2, keeping the longer of two lines...

output would ideally be

Code:
<string name="string1">RZ-LED</string>
<string name="string2">Version 2.0</string>
<string name="string3">BP</string>

Is this possible using GNU tools?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep and delete lines except the lines with strings

Hi I am writing a script which should read a file and search for certain strings 'approved' or 'removed' and retain only those lines that contain the above strings. Ex: file name 'test' test: approved package waiting for approval package disapproved package removed package approved... (14 Replies)
Discussion started by: vj8436
14 Replies

2. UNIX for Dummies Questions & Answers

Delete lines with duplicate strings based on date

Hey all, a relative bash/script newbie trying solve a problem. I've got a text file with lots of lines that I've been able to clean up and format with awk/sed/cut, but now I'd like to remove the lines with duplicate usernames based on time stamp. Here's what the data looks like 2007-11-03... (3 Replies)
Discussion started by: mattv
3 Replies

3. 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

4. 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

5. Shell Programming and Scripting

Getting lines between two strings with duplicate set of data

if I have the following lines in a file app.log some lines here <AAAA> abc <id>123456789</id> ddd </AAAA>some lines here too <BBBB> abc <id>123456789</id> ddd </BBBB>some lines here too <AAAA> xyz <id>987654321</id> ssss </AAAA>some lines here again... How do I get the... (5 Replies)
Discussion started by: nariwithu
5 Replies

6. Shell Programming and Scripting

Delete duplicate strings in a line

Hi, i need help to remove duplicates in my file. The problem is i need to delete one duplicate for each line only. the input file as follows and it is not tab delimited:- The output need to remove 2nd word (in red) that duplicate with 1st word (in blue). Other duplicates should remained... (12 Replies)
Discussion started by: redse171
12 Replies

7. UNIX for Dummies Questions & Answers

Replace some strings keeping others

I want to replace strings in test2 according to test1 table. In doing so, I`m losing records that I dont need to replace, please suggest modifications. what i have $ cat > test1 a b c d   $ cat > test2 a a a d d   what i tried $ awk ' BEGIN {FS=OFS=" "} FNR==NR{a=$2;next}... (2 Replies)
Discussion started by: senhia83
2 Replies

8. Shell Programming and Scripting

Remove lines containing 2 or more duplicate strings

Within my text file i have several thousand lines of text with some lines containing duplicate strings/words. I would like to entirely remove those lines which contain the duplicate strings. Eg; One and a Two Unix.com is the Best This as a Line Line Example duplicate sentence with the word... (22 Replies)
Discussion started by: martinsmith
22 Replies

9. UNIX for Beginners Questions & Answers

How to pass strings from a list of strings from another file and create multiple files?

Hello Everyone , Iam a newbie to shell programming and iam reaching out if anyone can help in this :- I have two files 1) Insert.txt 2) partition_list.txt insert.txt looks like this :- insert into emp1 partition (partition_name) (a1, b2, c4, s6, d8) select a1, b2, c4, (2 Replies)
Discussion started by: nubie2linux
2 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
x52output(1)						      General Commands Manual						      x52output(1)

NAME
x52output - command line frontend for the x52pro library SYNOPSIS
x52output text 0 'First Line' x52output text 1 'Second Line' x52output text 2 'Third Line' x52output bri 0 40 x52output bri 1 50 x52output led 1 1 # not available for old X52 x52output time 1 12 20 x52output date 7 10 17 x52output second 30 # YOKE only x52output offset 0 1 0 90 # set 90 minutes offset on time display 2 DESCRIPTION
x52output is a command line frontend for the x52pro MFD library. It is intended for debugging and/or scripting purposes. The x52pro MFD library provides access to the display/LEDS of following SAITEK pro flight devices o X52 Pro Flight Control System o X52 Flight Control System o X52 Pro Flight Yoke. x52output has following sub-commands: text line text Outputs a single line of text to one of the three lines on the x52/x52pro MFD. line is a number from 0 to 2, text is an alphanumeric text of length 16. Some graphical characters are also supported but no work has currently been spent on charset compatibility. bri mfd brightness Sets the brightness of either the button LEDs (x52pro only) or the MFD. mfd=0 selects the buttons and mfd=1 selects the MFD. brightness is a decimal value in the range from 0 to 127. led led-idx color Sets the led color of one of the x52pro buttons. led-idx is a value from 1 to 19. The meaning of the led-idx values are specified in the next paragraph. time h24 hour minute Sets the time shown on the MFD. h24=0 displays the time in AM/PM notation, h24=1 displays the time in 24 Hour notation. hour is a value from 0 to 24 while minute is a value from 0 to 60. date year month mday Sets the date shown on the MFD. year, month, and mday are just values from 0 to 99. Using this order will show as YY-MM-DD on the MFD but it is possible to use the three values in any order preferred. second second Sets the second value shown on the Pro Flight Yoke MFD. Can be a value from 0 to 59. offset offset Sets the time offset of the secondary and tertiary time display of the x52/x52pro MFD. idx=0 selects the secondary display while idx=1 selects the tertiary display. neg=0 sets a positive offset, neg=1 sets a negative offset. offset is in minutes from 0 to 1023. led-idx for the led sub-command can be one of the following values: 1 LED(s) of Fire Button 2 Red LED of A Button 3 Green LED of A Button 4 Red LED of B Button 5 Green LED of B Button 6 Red LED of D Button 7 Green LED of D Button 8 Red LED of E Button 9 Green LED of E Button 10 Red LED of T1 Switch 11 Green LED of T1 Switch 12 Red LED of T2 Switch 13 Green LED of T2 Switch 14 Red LED of T3 Switch 15 Green LED of T3 Switch 16 Red LED of Coolie Hat 17 Green LED of Coolie Hat 18 Red LED of i Button 19 Green LED of i Button x52output needs write access to the raw x52 USB device. This package is supplied with udev rules for providing write access on the SAITEK MFD joysticks to the plugdev group members. If x52output fails, permission problems can be checked by means of running it with sudo. EXIT STATUS
If the joystick/yoke is not found x52output will return a status code of 1. In every other situation it will return a status code of 0. This includes malformed command lines. BUGS
x52output can currently control only a single SAITEK mfd device. If there are more than one devices attached to the system, the first will always be used. AUTHOR
Written by Eduard Hasenleithner <eduard@hasenleithner.at> x52output(1)
All times are GMT -4. The time now is 11:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy