Announcement

Collapse
No announcement yet.

Bash shell eliminate a string pattern from a file

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bash shell eliminate a string pattern from a file

    hi guys,
    i am having a file where i need to take eliminate the a string pattern from input file.

    for eg
    list.txt
    Code:
    AUS
    USA

    input.txt
    AUS,123
    NZ,11
    US,13
    USA,12,
    USA,12,AUS
    AUSAA,1,2

    i need to eliminate the string from list.txt which matches the first string from input file

    desired output
    Code:
    NZ,11
    US,13
    USA,12,AUS
    AUSAA,1,2



  • #2
    Backup all files before you do this
    Code:
    while IFS= read -r p; do sed -ie "/^$p,/d" input.txt; done < list.txt
    All [Solved] threads are closed by mods / admin to avoid spam issues. See Howto mark a thread as [Solved]

    Comment

    Working...
    X