PDA

View Full Version : duplicate file to many


m3mary
10-02-2008, 06:17 AM
hello
how to do duplicate file.txt to file1.txt file2.txt file*.txt file100.txt


also


how to write on special file a code :
from <code1> to <code2>



removing the first code or adding to it

using ssh

Tom E.
10-02-2008, 08:47 AM
To make numbered copies, enter this on the command line:
(note the back-quotes on the first line)for i in `seq 1 100`;
do
cp file.txt file$i.txt
done
I'm not sure what you're asking in the second question.

-- Tom

m3mary
10-02-2008, 10:09 AM
i tried from 1 5 , gave me this error :
cp: copying multiple files, but last argument `5.txt' is not a directory

and there are no copies


second quistion asum in file.txt i have code :

<html>
<title>
975654
</html>


i want by ssh insert code in that file replacing 975654 by <body></body>

m3mary
10-02-2008, 10:21 AM
i did it without back-quotes and gave me:
file.txt
file1.txt
file5.txt
fileseq.txt

m3mary
10-02-2008, 10:29 AM
when i use seq 1 2 3 4 5 6 7 8 9 10
it gives me 10 files
good but if there is a way to do it 1 - 3 will be easier

Tom E.
10-02-2008, 10:40 AM
The error message sounds like what you'd get if you used single quotes.

Are you sure you used back quotes? (above the tab key, to the left of '1')

Are you running the command on an FQ account? (that's where I tested my answer)

Regarding the second question, do you want to insert the code into a single file, or lots of them?

If multiple files, you can do it with the 'sed' (stream editor) command or perl or some other scripting language.
I haven't used sed in a long time, but you can search the web for 'sed substitute example' to find what you need.

m3mary
10-02-2008, 11:13 AM
Ok the `seq 1 5` working now and gave me 5 files :yeah: thank you

second quistion i want it with a single file, i know the file name + i know it have a code line <-exmaple-> i want to replace it in just that file.

and 'sed ubstitute example' going to try it also in future..

Tom E.
10-02-2008, 12:27 PM
Since it's just one file, how about using the CNC File Manager to edit the file?

Or copy the file to your computer, edit it there, then upload the new file.

I wouldn't bother with sed to change a single file.

m3mary
10-02-2008, 12:51 PM
if i recive 200 new txts each day to be added very hard !
but if i do a code ssh (from repeating single code) will add them all one time saving time and effort.
it is single code for sigle file, but can be repeated to 100 pages each time

Tom E.
10-02-2008, 01:05 PM
I'm still not sure how you want this to work, but it sounds like a good use for a database - assuming you're talking about web pages.

You could enter all the new text into the database with phpMyAdmin or a custom form.

The pages that need the info could get it from the database instead of having to update the files every time.

m3mary
10-02-2008, 01:36 PM
Ok that is also good but how i do it..
Assume am getting 200 txt daily how i do a code to add them directly to a database with no interfere of me.
And how i retrieve them to be shown public ?
Also how to edit texts and remove others?

Of course without memberships and register

I think this going to designing side, which am poor on it, and am afraid am going to stray on it.

Tom E.
10-02-2008, 02:11 PM
Where does the new text come from?
- email? an RSS feed? a contact form?

How is the text going to be displayed?
- is it a web page? a report in a text file?

How many text updates are displayed at a time?
- only the most recent one? last 10? newer than 1 week?, etc.

Any of the options above can be accomplished with a custom solution, but somebody out there might know how to do it easily, depending on the details of your situation.

Perhaps a blog is what you're looking for to post and manage entries.

m3mary
10-02-2008, 02:40 PM
yes it is something like open source blog
but using free open source is full of risk and will not be controlled as am trying in style + way of working

i have thousands of images each img with -serial number- 0-0-0-0 each number will be connected to info related to that pic, if there is infos showing it, if there are no infos show "add info" form or not link it.

im tring to do it and it is easy to do it but manual, nothing going automatically

i prepare the txt amounts then add infos received each time and open the source for publics

that’s the whole idea and it is still idea

m3mary
10-02-2008, 03:13 PM
i think for adding txt it is easy now
do multiple files by serial num (for i) , download them, add infos, upload by zip, unzip in exact folder

but showing for publics i think should be by sed order you mintioned for instead of 'picture text' replace by '<link code refer=0-0-0-0.txt>picture txt</code>'

can be used for both txt infos and picture linking

going to learn more about 'sed' ssh
thank you alot

Tom E.
10-02-2008, 04:10 PM
I wouldn't recommend 'sed' or copying files any more, now that I know what you're trying to do.

It seems like gallery software might be what you want. You can upload photos, add captions, create thumbnails, set categories, as well as select different templates to view the photos.

I've never installed pre-packaged gallery software, but here's a recent thread on photo galleries (http://www.aota.net/forums/showthread.php?t=23715) in these forums.

m3mary
10-03-2008, 03:09 AM
i know image gallery it is not flixible + hard to browse for visitors.
not practicle for the way im adding and showing datas

again on the i loop, that gives me 1 20 in seq but not in
$a-$b-$c-$d.txt
a = 1 4
b = 1 8
c = 1 2
d = 1 20
some thing like that

Tom E.
10-03-2008, 09:09 AM
Is this what you mean?
for a in `seq 1 4`;
do
for b in `seq 1 8`;
do
for c in `seq 1 2`;
do
for d in `seq 1 20`;
do
echo $a-$b-$c-$d.txt
done
done
done
doneOnce it outputs the correct file names, replace the echo statement with the one to copy files.

And if you're not doing it already, put the script in a file so you don't have to type or copy/paste it each time you want to run it.

i know image gallery it is not flixible + hard to browse for visitors.There are many similar programs available; perhaps another one would suit your needs.

m3mary
10-03-2008, 10:48 AM
working, thanks alot
:yeah::yeah::yeah:

can this codes be used in Windows enviroment or they are just for linex kind servers

Tom E.
10-03-2008, 11:24 AM
You'll need a unix-like shell program to run scripts like this on windows.

The bash shell is what your FQ account is running.

m3mary
10-03-2008, 01:59 PM
im using putty-ssh, can i use it to do local orders

Tom E.
10-03-2008, 04:18 PM
I doubt it - though I haven't used putty, so I'm not sure.

SSH clients let you run commands on a remote computer, not the one you're sitting at.

You'll want to search on "bash for windows" or something like that to find what you're looking for.

Does anyone else here have a recommendation for bash on windows?

kitchin
10-03-2008, 05:33 PM
Another good reason to use perl.

Jeff
10-03-2008, 08:37 PM
Does anyone else here have a recommendation for bash on windows?
m3mary should install CentOS (http://www.centos.org/) or your linux flavor of choice on an old spare computer -- it's fun, useful, and educational :rasberry:

m3mary
10-05-2008, 07:05 AM
Ok thank you all im going to work on server
no need of additional programs

thanks Tom E and all others