Yes . the replacing was a new question but working on the same file.

and you are right it is turnning into a series. :D

btw, I got a solution already for the last one using a sed script.


#!/bin/sed -f

# split line
s/\(##[^#]*\)\(.*\)/\1\
\2/

# put second part in hold space
h;s/.*\n//
# and first part in pattern space
x;s/\n.*//
# replace all / with : in first part
s/\//:/g
# replace all _ with apce in first part
s/_/ /g
# append the second part
G;s/\n//

#end sed script



So here is a NEW question:

- I have a list of words "cat , dog, camel, bird, ...) 

I would like to put them in an array or a text file and run a loop on this 
command.

awk -F'##' 'BEGIN {IGNORECASE=1} $2 ~ /WORD-FROM-FILE/ { print }' infile > 
outputfile-WORD-FROM-FILE


I would like to know how to get the WORD-FROM-FILE used as pattern and added to 
the output file name please. I am still working on the same infile. 

:)


Abdallah 

----- Original Message -----
From: [EMAIL PROTECTED]
To: "Jordan Linux User Group Mailing list" <[email protected]>
Subject: Re: [JoLUG-General] brain picking
Date: Mon, 2 May 2005 08:51:09 +0300 (EEST)

> 
> Walakum Alsalam Wa Rahmato Alah,
> 
> I just want to make this clearer; now you're asking for "replacing" and
> not greping; and so this is another question of the brain picking series
> right?
> 
> Ali Al-Khalidi
> > Salam Ali
> >
> >
> > How do I work on the same file but this time I am replacing a characher
> > in the fisrt section ?
> >
> > I would like to replace every "|" with a ","  but only in the left side.
> >
> >
> > Abdallah
> >
> >
> >
> >
> >
> >
> > ----- Original Message -----
> > From: [EMAIL PROTECTED]
> > To: "Jordan Linux User Group Mailing list" <[email protected]>
> > Subject: Re: [JoLUG-General] brain picking
> > Date: Sat, 23 Apr 2005 13:47:57 +0300 (EEST)
> >
> >>
> >> Salam Abdullah,
> >>
> >> Miss ya man, really; mail me updates on your status where you are.
> >>
> >> about the quiz:
> >> File Format:
> >>
> >> ##some in section one##another in section two##yet another in three line
> >> one
> >> ##some in section one##another in section two##yet another in three line
> >> two
> >>
> >> ./abdula.sh word file
> >>
> >> #!/bin/bash
> >> grep "^##[[:space:][:alpha:]]*\($1\)[[:space:][:alpha:]]*##" $2
> >>
> >> cheerz,
> >>
> >> Ali Al-Khalidi
> >>
> >>
> >> > Salaam Alaikum Khamis Al3azeez
> >> >
> >> > Good morning to ya.
> >> >
> >> > True, but we are not working with dirs. They are hiarchical listings
> >> of
> >> > words in a text file.
> >> >
> >> > Any idea about the second quiz ? :)
> >> >
> >> >
> >> >
> >> > ----- Original Message -----
> >> > From: "Khamis Siksek" <[EMAIL PROTECTED]>
> >> > To: "Jordan Linux User Group Mailing list" <[email protected]>
> >> > Subject: Re: [JoLUG-General] brain picking
> >> > Date: Sat, 23 Apr 2005 09:44:56 +0300
> >> >
> >> >>
> >> >> I think this is the fastest and the easiest
> >> >>
> >> >> find ./ -type d
> >> >>
> >> >> and a sorted list of directories will appear
> >> >>
> >> >>
> >> >>
> >> >> On 4/23/05, Abdallah <[EMAIL PROTECTED]> wrote:
> >> >> > Abulyomon is the man.
> >> >> >
> >> >> > here is another way:
> >> >> >
> >> >> > awk '{sub(/\/$/, "", $0) ; n=split($0, b, /\//) ; if (b[2]) for
> >> >> > (y=1;y<=n;y++) { printf b[1] ; for (z=2;z<=y;z++) printf filename
> >> >> >
> >> >> > however, yours is faster. Thanks my frind. I did enjoy.
> >> >> >
> >> >> > Here is another one:
> >> >> >
> >> >> > A file
> >> >> >
> >> >> > ##section 1 words## section 2 a bunch of words##section 3 other
> >> words
> >> >> > ##section 1 words## section 2 a bunch of words##section 3 other
> >> words
> >> >> > ##section 1 words## section 2 a bunch of words##section 3 other
> >> words
> >> >> >
> >> >> > I would like to grep for words in section 1 only and if they
> >> >> > match then output the whole line as is.
> >> >> >
> >> >> > :)
> >> >> >
> >> >> > ----- Original Message -----
> >> >> > From: "Yaman Saqqa" <[EMAIL PROTECTED]>
> >> >> > To: "Jordan Linux User Group Mailing list" <[email protected]>
> >> >> > Subject: Re: [JoLUG-General] brain picking
> >> >> > Date: Sat, 23 Apr 2005 02:56:15 +0200
> >> >> >
> >> >> > >
> >> >> > > mnee7 elli tzakkartna man ... it's really good to see ur name in
> >> >> > > the list again.
> >> >> > >
> >> >> > > btw .. here is the script .. enjoy
> >> >> > >
> >> >> > >
> >> >> > > [EMAIL PROTECTED] junk]$ cat data
> >> >> > > a/e/d/f/
> >> >> > > d/g/r/t/d/f/f/
> >> >> > > [EMAIL PROTECTED] junk]$ ./abdallah data
> >> >> > > a
> >> >> > > a/e
> >> >> > > a/e/d
> >> >> > > a/e/d/f
> >> >> > > d
> >> >> > > d/g
> >> >> > > d/g/r
> >> >> > > d/g/r/t
> >> >> > > d/g/r/t/d
> >> >> > > d/g/r/t/d/f
> >> >> > > d/g/r/t/d/f/f
> >> >> > > [EMAIL PROTECTED] junk]$ cat abdallah
> >> >> > > #!/bin/bash
> >> >> > >
> >> >> > > DATAFILE=$1
> >> >> > >
> >> >> > > for line in `cat $DATAFILE`
> >> >> > > do
> >> >> > >          PARTS=`echo $line | tr '/' ' ' | wc -w`
> >> >> > >          for ((part=1; part <= PARTS ; part++))
> >> >> > >          do
> >> >> > >                  echo $line | cut -d '/' -f -$part
> >> >> > >          done
> >> >> > > done
> >> >> > >
> >> >> > >
> >> >> > > On 4/23/05, Abdallah <[EMAIL PROTECTED]> wrote:
> >> >> > > > Assalam Alaikum Wr Wb
> >> >> > > >
> >> >> > > > How are you all?
> >> >> > > >
> >> >> > > > I have been following the list on and off since I left and I am
> >> >> > > > so glad of the traffic it has. I can tell that you guys are up
> >> to
> >> >> > > > no good. :D
> >> >> > > >
> >> >> > > > Anyway, I have a question for you guys.
> >> >> > > >
> >> >> > > > I have a file as such:
> >> >> > > >
> >> >> > > > a/e/d/f/
> >> >> > > > d/g/r/t/d/f/f/
> >> >> > > > ..
> >> >> > > > ..
> >> >> > > >
> >> >> > > >  How can I sort it to look like this:
> >> >> > > >
> >> >> > > > a
> >> >> > > > a/e
> >> >> > > > a/e/d
> >> >> > > > a/e/d/f
> >> >> > > > d
> >> >> > > > d/g
> >> >> > > > d/g/r
> >> >> > > > d/g/r/t
> >> >> > > > d/g/r/t/d
> >> >> > > > d/g/r/t/d/f
> >> >> > > > d/g/r/t/d/f/f
> >> >> > > > ....
> >> >> > > > .....
> >> >> > > >
> >> >> > > > how can I use tools like awk, sed, cut or whatever else you can
> >> >> > > > think of ..... to do it?
> >> >> > > >
> >> >> > > > notice:
> >> >> > > > - that the letters could be words of various lengths.
> >> >> > > >
> >> >> > > > Abdallah
> >> >> > > >
> >> >> > > > --
> >> >> > > > ___________________________________________________________
> >> >> > > > Sign-up for Ads Free at Mail.com
> >> >> > > > http://promo.mail.com/adsfreejump.htm
> >> >> > > >
> >> >> > > > _______________________________________________
> >> >> > > > General mailing list
> >> >> > > > [email protected]
> >> >> > > > http://mail.jolug.org/mailman/listinfo/general_jolug.org
> >> >> > > >
> >> >> > >
> >> >> > >
> >> >> > > --
> >> >> > > abulyomon
> >> >> > >
> >> >> > > www.KiLLTHeUPLiNK.com
> >> >> > >
> >> >> > > _______________________________________________
> >> >> > > General mailing list
> >> >> > > [email protected]
> >> >> > > http://mail.jolug.org/mailman/listinfo/general_jolug.org
> >> >> >
> >> >> > --
> >> >> > ___________________________________________________________
> >> >> > Sign-up for Ads Free at Mail.com
> >> >> > http://promo.mail.com/adsfreejump.htm
> >> >> >
> >> >> > _______________________________________________
> >> >> > General mailing list
> >> >> > [email protected]
> >> >> > http://mail.jolug.org/mailman/listinfo/general_jolug.org
> >> >> >
> >> >>
> >> >>
> >> >> --
> >> >>
> >> >>
> >> >> Khamis Siksek
> >> >>
> >> >> When they thought of finding another name for FreeSoftware, they
> >> >> thought of OpenSource and KhamisSiksek ...
> >> >> .
> >> >> .
> >> >> .
> >> >> They chose the wrong one :-(
> >> >>
> >> >> _______________________________________________
> >> >> General mailing list
> >> >> [email protected]
> >> >> http://mail.jolug.org/mailman/listinfo/general_jolug.org
> >> >
> >> > --
> >> > ___________________________________________________________
> >> > Sign-up for Ads Free at Mail.com
> >> > http://promo.mail.com/adsfreejump.htm
> >> >
> >> >
> >> > _______________________________________________
> >> > General mailing list
> >> > [email protected]
> >> > http://mail.jolug.org/mailman/listinfo/general_jolug.org
> >> >
> >>
> >>
> >> _______________________________________________
> >> General mailing list
> >> [email protected]
> >> http://mail.jolug.org/mailman/listinfo/general_jolug.org
> >
> > --
> > ___________________________________________________________
> > Sign-up for Ads Free at Mail.com
> > http://promo.mail.com/adsfreejump.htm
> >
> >
> > _______________________________________________
> > General mailing list
> > [email protected]
> > http://mail.jolug.org/mailman/listinfo/general_jolug.org
> >
> 
> 
> _______________________________________________
> General mailing list
> [email protected]
> http://mail.jolug.org/mailman/listinfo/general_jolug.org

-- 
___________________________________________________________
Sign-up for Ads Free at Mail.com
http://promo.mail.com/adsfreejump.htm


_______________________________________________
General mailing list
[email protected]
http://mail.jolug.org/mailman/listinfo/general_jolug.org

Reply via email to