Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. whatisthis987

    How do I replace just the second pattern?

    Thanks PHV for the solution. The s! was giving me some problem so I modified it and added \s to remove the spaces before aaa. tr ';\n' '\n;' <FILE | sed '/^;*\s*aaa /s/ ccc ddd$' | tr '\n;' ';\n'
  2. whatisthis987

    How do I replace just the second pattern?

    Hi PHV, No, I don't want any other lines that begins with non-"aaa" to change. For example: basas sdsa asda ccc ddd; should not change. Just to simplify my test case: aaa 111 222 ccc ddd; aaa dfg dffd dfdfd sdfdsf dfdf dfd fdgdfg dfgdg dfgd dgfd gdgdf fdsfs ccc ddd; basas sdsa asda ccc...
  3. whatisthis987

    How do I replace just the second pattern?

    Thanks but I also want: from: aaa dfg dffd dfdfd sdfdsf dfdf dfd fdgdfg dfgdg dfgd dgfd gdgdf fdsfs ccc ddd; to: aaa dfg dffd dfdfd sdfdsf dfdf dfd fdgdfg dfgdg dfgd dgfd gdgdf fdsfs; Any help?
  4. whatisthis987

    SED - find and replace between patterns

    Thanks PHV and p5wizard for the replies but I also want: from: aaa dfg dffd dfdfd sdfdsf dfdf dfd fdgdfg dfgdg dfgd dgfd gdgdf fdsfs ccc ddd; to: aaa dfg dffd dfdfd sdfdsf dfdf dfd fdgdfg dfgdg dfgd dgfd gdgdf fdsfs; Any help?
  5. whatisthis987

    SED - find and replace between patterns

    Hi, I would like to search between "aaa" and ";" for "ccc ddd" and replace it with a blank. To me, each "line" of interest begins with "aaa" and ends with a semicolon ";". For example, aaa 111 222 ccc ddd; sdfs fdd ccc ddd; sfsdf dfdf fdf dfff dfsdfs fdfd; aaa dfg ccc ccc ddd; aaa ddd ccc ccc...
  6. whatisthis987

    How do I replace just the second pattern?

    Sorry for the confusion. I had a typo in my example. No, not remove the last 2 fields of every line that ends with a semicolon. I want to search between "aaa" and ";" for "ccc ddd" and replace it with blank. I corrected and here's another test case: aaa 111 222 ccc ddd; sdfs fdd ccc ddd...
  7. whatisthis987

    How do I replace just the second pattern?

    Well, I just figured out how to do it with sed. sed '/aaa/s/ ccc ccc;/;/g' FILE but i have a more complicated case like this: aaa bbb 222 333 444 eee ccc ddd; eee ccc ddd; I want it to be: aaa bbb 222 333 444 eee; eee ccc ddd; which means a line always end with a semicolon ";"...
  8. whatisthis987

    How do I replace just the second pattern?

    Hi, I have a file looks like this: aaa bbb ccc ddd; 123 321 423 444; aaa eee ccc ddd; aaa fff ccc ddd; 12243455465467; I want the output to look like this: aaa bbb; 123 321 423 444; aaa eee; aaa fff; 12243455465467; Basically, just remove the last 2 entries of the lines begin with "aaa" but...
  9. whatisthis987

    Addition

    Hi, I have a file that looks like this: textxxxxxx abc 100 200 text again.....300 100 more text...... (5853.2775,2960.825) (5853.275, 2960.82) (5853.28, 2960.83) (6185.3225,6330.975) (6185.32, 6330.97) (6185.325, 6330.98) I would like to add 10 to the numbers of...
  10. whatisthis987

    How to subtract only the lines with 2 numerical columns

    Thank you so much. That's exactly what I wanted. Really appreaciate your help.
  11. whatisthis987

    How to subtract only the lines with 2 numerical columns

    Hi, I have a file that looks like this: line1 - This is line #1 line1 - This is line #1 11 11 11 500 600 600 700 700 800 line7 - This is line #7 line8 - This is line #8 I would like to subtract 10 ONLY from the lines with 2 numerical columns. Meaning it should look like this: line1 - This is...
  12. whatisthis987

    How to break a file into pieces?

    Thank again for the solution and detail explanation. Perhaps the previous testcase isn't a good one. Here's what I really want. === Input file === 123 45676 677 par123.123 sfsf sf dsfsd sfd s wefrewr23 23432 53 65 5 dgasgd.4354ssd sdfs{#$%$#%$%!!!@ et g trhrt werd wewete 24356 655b56 fg d...
  13. whatisthis987

    How to break a file into pieces?

    Actually, I am intending to filter out those Parxxx with line length > 1. set length [llength $line] if {$length==1} { set result [regexp {(^Par\d+)} $line match fname] if {$result==1} { #open output_file #set file_opened to 1 ... ... .. so if the paragraph starts with "Par123 sas...
  14. whatisthis987

    How to break a file into pieces?

    By the way, assuming some of the lines ($line) consist of special characters like "} % #..", what can be done to ignore those special characters in $line?
  15. whatisthis987

    How to break a file into pieces?

    Excellent! You deserve a star from me, mikrom.
  16. whatisthis987

    How to break a file into pieces?

    Thanks but there is a problem if the merge_file.txt does not begin with "Par". It would error out "can't read "output_file": no such variable.
  17. whatisthis987

    How to break a file into pieces?

    Hi, I have a file that looks like this: Par1 sdfsdff c 568768 dfdfdfdty6v 655 dfdsdfd 1243 END1abcd Par2 tyrtyrfghgfh rtytrfg gffg gfhjkk dffg END2abcd I would like to write a TCL script to split what's between Par and END into seperate files. For example, ::File Par1.txt:: Par1 sdfsdff c...
  18. whatisthis987

    How to print one line before and one line after certain pattern?

    Thank you guys. I never knew the usage of -A and -B. This is perfect.
  19. whatisthis987

    How to print one line before and one line after certain pattern?

    Hi guys, I would like to print the line before and the line after "JohnDoe" is found. For example, ===Input text file=== line1 line2 JohnDoe blah blah blah line4 line5 ===Desired output file=== line2 line4 Can someone suggest a good way of doing this?
  20. whatisthis987

    How do I remove duplicate values?

    Nevermind. A simple if loop in Excel does the trick.

Part and Inventory Search

Back
Top