Re: Appending filename to each line in the file

2010-06-05 Thread wallabadah
Assuming the filenames end with .txt and have no spaces. TAB=$(printf "\t"); for n in $(ls); do TITLE=$(basename -s .txt $ {n} ); cat ${n} | sed -E "s/$/${TAB}${TITLE}/g" > ${TITLE}_new.txt; done; Will. On May 29, 4:18 am, LuKreme wrote: > On 28-May-2010, at 07:48, Tim Gray wrote: > > > On May

Re: Appending filename to each line in the file

2010-05-28 Thread LuKreme
On 28-May-2010, at 07:48, Tim Gray wrote: > On May 28, 2010 at 07:40 AM -0500, dp wrote: >> I have 57 files. Each contains a list of student names. In order to import >> into a database, I need to append the filename to the end of each line in >> each file. To use a simplified example, the Basket

Re: Appending filename to each line in the file

2010-05-28 Thread Tim Gray
On May 28, 2010 at 09:10 AM -0500, dp wrote: If only I knew how. But it's a moot point. I finally bit the bullet and did it file by file. It was tedious, but not as time-consuming as I had expected. I won't write one up then :) It is a skill worth acquiring if you do this kind of stuff period

Re: Appending filename to each line in the file

2010-05-28 Thread dp
If only I knew how. But it's a moot point. I finally bit the bullet and did it file by file. It was tedious, but not as time-consuming as I had expected. Thanks, Tim. *** On May 28, 2010, at 8:48 AM , Tim Gray wrote: On May 28, 2010 at 07:

Re: Appending filename to each line in the file

2010-05-28 Thread Tim Gray
On May 28, 2010 at 07:40 AM -0500, dp wrote: I have 57 files. Each contains a list of student names. In order to import into a database, I need to append the filename to the end of each line in each file. To use a simplified example, the Basketball_Boys.tab file contains Sounds like the job f

Re: Appending filename to each line in the file

2010-05-28 Thread dp
I'll experiment with that. Thanks, Steve. *** On May 28, 2010, at 8:30 AM , Steve Kalkwarf wrote: Yes, it's easy for one file, and I'll do it that way if necessary. I was rather hoping for some function that allowed a multi-file replacement

Re: Appending filename to each line in the file

2010-05-28 Thread Steve Kalkwarf
> Yes, it's easy for one file, and I'll do it that way if necessary. I was > rather hoping for some function that allowed a multi-file replacement of \r > with \t[filename]\r. There is no token for filename in the replace mechanics, but you could write an AppleScript to do this: tell applicati

Re: Appending filename to each line in the file

2010-05-28 Thread dp
Thanks, Brian. Yes, it's easy for one file, and I'll do it that way if necessary. I was rather hoping for some function that allowed a multi-file replacement of \r with \t[filename]\r. dp *** On May 28, 2010, at 7:49 AM , Brian Frick wrot

Re: Appending filename to each line in the file

2010-05-28 Thread Brian Frick
At the very least, you could do Text -> Prefix/Suffix lines with " \t Basketball_Boys " in suffix for that file. You'd have to do each file separately, but that's super easy. -- Brian On May 28, 2010, at 7:40 AM, dp wrote: > I have 57 files. Each contains a list of student names. In order t

Appending filename to each line in the file

2010-05-28 Thread dp
I have 57 files. Each contains a list of student names. In order to import into a database, I need to append the filename to the end of each line in each file. To use a simplified example, the Basketball_Boys.tab file contains Andy [tab] Aardvark Billy [tab] Badger Carl [tab] Cougar I need for