Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2010
    Posts
    72

    Unanswered: Formatting the words in a file

    I have a file named test which has content like below

    abc
    123
    456
    jshd
    uieh
    sjdfsdf
    sjdfhjkah
    jeff
    jenny


    I want the result as

    'abc','123','456','jshd','uieh','sjdfsdf','sjdfhjk ah','jeff','jenny'

    after formatting the above string

    I have one logfile which has thousands of rows. From this file I have to select the lines which does not has any of the string from the file 'test'

    please let me know how to do

  2. #2
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    Traditionally homework is set for students to allow them to practice what they've learnt, not for students to hand it out to others to do.

  3. #3
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    Code:
    #!/bin/ksh
    LIST=; export LIST
    separator=" "
    while read token
    do
            LIST=$LIST$separator$token
            separator=" |"
    done <testfile
    grep -E -v "$LIST" logfile >/exceptionlist
    Damn, I see a mistake in it.
    Last edited by kitaman; 01-25-10 at 20:34.

  4. #4
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool Read The Fine Manual

    Quote Originally Posted by regtha View Post
    please let me know how to do
    man grep

    SYNTAX
    grep <options> [-f file] [file...]

    OPTIONS
    `-f FILE'
    Obtain patterns from FILE, one per line. The empty file contains
    zero patterns, and therefore matches nothing.

    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Posting Permissions

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