From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adam Bowen Subject: Re: need help with a bash script Date: Tue, 19 Sep 2006 20:53:41 +0100 Message-ID: <45104AC5.8000709@agitate.org.uk> References: <4510402A.8090703@fcaglp.unlp.edu.ar> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <4510402A.8090703@fcaglp.unlp.edu.ar> Sender: linux-admin-owner@vger.kernel.org List-Id: Content-Type: text/plain; charset="us-ascii"; format="flowed" To: zyserman@fcaglp.unlp.edu.ar Cc: linux-admin@vger.kernel.org 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