Re: concatentate file name in batch
- From: Tino <spartacus.ist.adam.weishaupt@xxxxxxxxxxxxxx>
- Date: Wed, 06 Oct 2010 16:10:33 +0200
On 07.10.2010 05:31, ela wrote:
Is there any unix command that can add the file name to the first line of a
file?
I want to use the following script to add headers in batch
#!/bin/sh
#set -x
for i in `ls $1`
do
concatenate_file_name $i
done
e.g. input files in directory TEST
a.txt
b.txt
a.txt:
I am a boy
b.txt
you are a girl
==>
a.txt.modified
a.txtI am a boy
b.txt.modified
b.txtyou are a girl
#!/bin/bash
for i in `ls $1`
do
cat $i > temp #save data
echo $i > $i #write filename to file
cat temp >> $i #append data to file
done
rm temp
I think there are better ways, but this would work!
.
- Follow-Ups:
- Re: concatentate file name in batch
- From: ela
- Re: concatentate file name in batch
- References:
- concatentate file name in batch
- From: ela
- concatentate file name in batch
- Prev by Date: Re: Sending a keep alive signal to remote terminal
- Next by Date: Laptop does not resume after suspend to ram
- Previous by thread: concatentate file name in batch
- Next by thread: Re: concatentate file name in batch
- Index(es):
Relevant Pages
|