Results 1 to 2 of 2

Thread: Bash shell eliminate a string pattern from a file

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default 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. #2
    Never say die nixcraft's Avatar
    Join Date
    Jan 2005
    Location
    BIOS
    Posts
    4,515
    Thanks
    17
    Thanked 814 Times in 511 Posts
    Rep Power
    10

    Default

    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]


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 16th September 2013, 01:53 AM
  2. String Pattern Using grep Command
    By numerouno in forum Shell scripting
    Replies: 1
    Last Post: 27th May 2013, 09:33 PM
  3. split files by specifying a string (bash shell)
    By vikas027 in forum Shell scripting
    Replies: 7
    Last Post: 21st June 2010, 12:35 PM
  4. [Solved] Delimiting a string in bash to run shell commands and pipes
    By iaroot in forum Shell scripting
    Replies: 2
    Last Post: 23rd January 2010, 01:01 AM
  5. Replies: 8
    Last Post: 5th November 2009, 08:14 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •