SUMMARY: short script to cat filename

From: Mike's List <mikelist_at_sky.net>
Date: Wed Jan 21 2004 - 12:11:56 EST
This script from Richard Lacroix works perfectly, exactly what I needed.

-----begin-----

#!/bin/sh
#
# Courtesy of Richard Lacroix
#
i="00001"
while true
do
echo $i
i=`expr $i + 1`
if [ $i -lt "10" ]
then
        i="0000"$i
elif [ $i -lt "100" ]
then
        i="000"$i
elif [ $i -lt "1000" ]
then
        i="00"$i
elif [ $i -lt "10000" ]
then
        i="0"$i
fi

cat somedire/file$i.txt > mydir/file$i.txt

if [ $i = "25000" ]
then
        exit
fi
done

-----end-----

Thanks for all the responses.  There are three-four more scripts which
follows the same pattern for which I have not tested.  My situation is
weird as a lot of people suggests ls/cd/cp commands into the script, which
is not an option.


- Mike

[ In addition to www.sunfreeware.com more packages at ftp.patriots.net ]


---------- Forwarded message ----------
Date: Wed, 21 Jan 2004 10:03:17 -0600 (CST)
From: Mike's List <mikelist@sky.net>
To: sunmanagers@sunmanagers.org
Subject: UPDATE: short script to cat filename

I apologized for any confusion of my post due to the late hours...
but what I want to accomplish is as follows: (cat is the ONLY option,
no cp/mv/ls/etc.)

#!/bin/sh
cat /somedir/file00000.txt > /mydir/file00000.txt
...
cat /somedir/file25000.txt > /mydir/file25000.txt

Yank/copy and search/replace 25k times within vi for a script is not an
option and not too productive.  I have the below in a script, but it's
not working.  I do not want to >> to one large file.

#!/bin/sh
# Somehow variable i needs to equal to 00000 to 25000 as the filenames
# are file00000.txt through file25000.txt, note, $i needs to increment
# by 00000 to 00001 to 00002 and so on, not 1, 2, 3...25000.
for i in *
do
cat /somedir/file$i.txt > /mydir/file$i.txt
done


- Mike


---------- previous message ----------

I have over 25000 small text files that I can only displays on screen
and cannot mv or cp.  Could someone forward me a short script to do the
following:

cat file00000.txt - file25000.txt > file00000.txt - file25000.txt

I'm thinking of the below, but I'm not a script expert.

#!/bin/ksh
for i = 0-25000
do
cat file$i.txt > file$i.txt
end

Basically, cat 25000 small files and piping it into the same filename.
Late project, hopefully someone is reading the list this late.  Thanks.


- Mike

[ In addition to www.sunfreeware.com more packages at ftp.patriots.net ]
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Wed Jan 21 12:11:46 2004

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:27 EST