* need help with a bash script
@ 2006-09-19 19:08 Fabio Zyserman
2006-09-19 19:53 ` Adam Bowen
0 siblings, 1 reply; 7+ messages in thread
From: Fabio Zyserman @ 2006-09-19 19:08 UTC (permalink / raw)
To: linux-admin
Hi all,
sorry if this is not the appropriate list to post my question,
but surely more than one guru here will be able to
guide me in my modest quest.
Here is my problem:
I have a lot of data files, which differ in their name by a number,
for example:
data-theta=0-np=1.2
data-theta=0-np=1.3
data-theta=0-np=1.4,
...and so on.
All files have the same structure (same number of columns and lines);
each single entry is a real number in free exp format, i.e. it looks
like this:
0.1224e01, but it is not important, I think
What I want to do is to create a new file, with one line from each of the
data files (say, line beginning with 0.01e00), adding to each line in
the new file the number appearing in the name of the corresponding data
file.
That is, the new file will contain one more column than the original
ones; the new
file would be
0.01e00 .... .... .... 1.2
0.01e00 .... .... .... 1.3
0.01e00 .... .... .... 1.4
.
.
Hope you can help!!!!
Many Thanks in advance!
Fabio Zyserman
^ permalink raw reply [flat|nested] 7+ messages in thread
* need help with a bash script
@ 2006-09-19 19:13 Fabio Zyserman
2006-09-19 19:44 ` Adrian C.
2006-09-19 19:53 ` Brett Zimmerman
0 siblings, 2 replies; 7+ messages in thread
From: Fabio Zyserman @ 2006-09-19 19:13 UTC (permalink / raw)
To: linux-admin
Hi all,
sorry if this is not the appropriate list to post my question,
but surely more than one guru here will be able to
guide me in my modest quest.
Here is my problem:
I have a lot of data files, which differ in their name by a number,
for example:
data-theta=0-np=1.2
data-theta=0-np=1.3
data-theta=0-np=1.4,
...and so on.
All files have the same structure (same number of columns and lines);
each single entry is a real number in free exp format, i.e. it looks
like this:
0.1224e01, but it is not important, I think
What I want to do is to create a new file, with one line from each of the
data files (say, line beginning with 0.01e00), adding to each line in
the new file the number appearing in the name of the corresponding data
file.
That is, the new file will contain one more column than the original
ones; the new
file would be
0.01e00 .... .... .... 1.2
0.01e00 .... .... .... 1.3
0.01e00 .... .... .... 1.4
.
.
Hope you can help!!!!
Many Thanks in advance!
Fabio Zyserman
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: need help with a bash script
2006-09-19 19:13 need help with a bash script Fabio Zyserman
@ 2006-09-19 19:44 ` Adrian C.
2006-09-19 19:53 ` Brett Zimmerman
1 sibling, 0 replies; 7+ messages in thread
From: Adrian C. @ 2006-09-19 19:44 UTC (permalink / raw)
To: zyserman; +Cc: linux-admin
Fabio Zyserman wrote:
> What I want to do is to create a new file, with one line from each of the
> data files (say, line beginning with 0.01e00), adding to each line in
> the new file the number appearing in the name of the corresponding data
> file.
> That is, the new file will contain one more column than the original
> ones; the new
> file would be
> 0.01e00 .... .... .... 1.2
> 0.01e00 .... .... .... 1.3
> 0.01e00 .... .... .... 1.4
rm -f newfile
for i in `ls data-*`
do
ls $i
printf `cat "$i" | grep -i "0.01e00"` >> newfile
printf ".........." >> newfile
printf `basename $i | cut -d = -f 3` >> newfile
printf "\n" >> newfile
done
well.. you get the idea.
--Adrian.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: need help with a bash script
2006-09-19 19:08 Fabio Zyserman
@ 2006-09-19 19:53 ` Adam Bowen
0 siblings, 0 replies; 7+ messages in thread
From: Adam Bowen @ 2006-09-19 19:53 UTC (permalink / raw)
To: zyserman; +Cc: linux-admin
Hi,
Fabio Zyserman wrote:
> Hi all,
>
> sorry if this is not the appropriate list to post my question,
> but surely more than one guru here will be able to
> guide me in my modest quest.
>
> Here is my problem:
>
>
> I have a lot of data files, which differ in their name by a number,
> for example:
> data-theta=0-np=1.2
> data-theta=0-np=1.3
> data-theta=0-np=1.4,
> ...and so on.
>
> All files have the same structure (same number of columns and lines);
> each single entry is a real number in free exp format, i.e. it looks
> like this:
> 0.1224e01, but it is not important, I think
>
> What I want to do is to create a new file, with one line from each of the
> data files (say, line beginning with 0.01e00), adding to each line in
> the new file the number appearing in the name of the corresponding data
> file.
> That is, the new file will contain one more column than the original
> ones; the new
> file would be
> 0.01e00 .... .... .... 1.2
> 0.01e00 .... .... .... 1.3
> 0.01e00 .... .... .... 1.4
Something like this should do it (if you were searching for 0.01e00):
grep 0.01e00 data-theta=0-np=* | sed
's/^data-theta=0-np=\([^:]*\):\(.*\)/\2 \1/'
Cheers
Adam
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: need help with a bash script
2006-09-19 19:13 need help with a bash script Fabio Zyserman
2006-09-19 19:44 ` Adrian C.
@ 2006-09-19 19:53 ` Brett Zimmerman
1 sibling, 0 replies; 7+ messages in thread
From: Brett Zimmerman @ 2006-09-19 19:53 UTC (permalink / raw)
To: Fabio Zyserman; +Cc: linux-admin
On Tue, 19 Sep 2006, Fabio Zyserman wrote:
> Hi all,
>
> sorry if this is not the appropriate list to post my question,
> but surely more than one guru here will be able to
> guide me in my modest quest.
>
> Here is my problem:
>
>
> I have a lot of data files, which differ in their name by a number,
> for example:
> data-theta=0-np=1.2
> data-theta=0-np=1.3
> data-theta=0-np=1.4,
> ...and so on.
>
> All files have the same structure (same number of columns and lines);
> each single entry is a real number in free exp format, i.e. it looks
> like this:
> 0.1224e01, but it is not important, I think
>
> What I want to do is to create a new file, with one line from each of the
> data files (say, line beginning with 0.01e00), adding to each line in
> the new file the number appearing in the name of the corresponding data
> file.
> That is, the new file will contain one more column than the original
> ones; the new
> file would be
> 0.01e00 .... .... .... 1.2
> 0.01e00 .... .... .... 1.3
> 0.01e00 .... .... .... 1.4
> .
> .
> Hope you can help!!!!
>
> Many Thanks in advance!
>
You probably want something along these lines:
#!/bin/bash
for file in `ls|grep data-theta`;
do
number=$(echo $file|awk -F '=' '{print $3}');
line=$(grep '0.01e00' $file);
echo $line $number;
done;
Hope that helps.
-bz
--
Brett Zimmerman
zim@oscer.ou.edu
(405)826-5104
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: need help with a bash script
@ 2006-09-20 14:04 Fabio Zyserman
[not found] ` <430c159a0609202108n2390802ar86e91c3fdf7637bd@mail.gmail.com>
0 siblings, 1 reply; 7+ messages in thread
From: Fabio Zyserman @ 2006-09-20 14:04 UTC (permalink / raw)
To: linux-admin; +Cc: zim, adamb, office
Hi, this is to say thanks a lot,
I was able to do what I wanted.
Regards,
Fabio Zyserman
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: need help with a bash script
[not found] ` <430c159a0609202108n2390802ar86e91c3fdf7637bd@mail.gmail.com>
@ 2006-09-21 4:10 ` Atishay Kumar
0 siblings, 0 replies; 7+ messages in thread
From: Atishay Kumar @ 2006-09-21 4:10 UTC (permalink / raw)
To: zyserman; +Cc: linux-admin, zim, adamb, office
comp.unix.shell usenet group is the right group for this :)
Though i firmely believe many shell queries could be solved on linux-admin -;
cheers
--
Atishay
On 9/21/06, Atishay Kumar <atishay.kumar@gmail.com> wrote:
>
> comp.unix.shell usenet group is the right group for this :)
>
> Though i firmely believe many shell queries could be solved on linux-admin -;
>
> cheers
> --
> Atishay
>
>
>
> On 9/20/06, Fabio Zyserman < zyserman@fcaglp.unlp.edu.ar> wrote:
> > Hi, this is to say thanks a lot,
> > I was able to do what I wanted.
> >
> > Regards,
> >
> > Fabio Zyserman
> > -
> > To unsubscribe from this list: send the line "unsubscribe linux-admin" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> >
>
>
>
>
> --
> :)
> Atishay Kumar
>
> /**************************************
> *All that is gold does not glitter *
> **************************************/
--
:)
Atishay Kumar
/**************************************
*All that is gold does not glitter *
**************************************/
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-09-21 4:10 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-19 19:13 need help with a bash script Fabio Zyserman
2006-09-19 19:44 ` Adrian C.
2006-09-19 19:53 ` Brett Zimmerman
-- strict thread matches above, loose matches on Subject: below --
2006-09-20 14:04 Fabio Zyserman
[not found] ` <430c159a0609202108n2390802ar86e91c3fdf7637bd@mail.gmail.com>
2006-09-21 4:10 ` Atishay Kumar
2006-09-19 19:08 Fabio Zyserman
2006-09-19 19:53 ` Adam Bowen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).