LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   Coding question (https://www.linuxquestions.org/questions/debian-26/coding-question-218023/)

quentusrex 08-15-2004 05:55 PM

Coding question
 
I'll admit this probably isn't the best place to ask this, but I have a coding question. I'm in the process of moving certain files from one WinXP pro partition to my debian partition and I would like to automate it. I'm trying to copy all my text documents throughout the WinXP partition that have the text 'school' in the title. I'd like it to go into my /home directory. this is the command i've come up with so far. i think i need a way to get the stdout to be put into the '$here' place.


find|grep school|cp $here /home


does anyone know of a good way to manipulate the stdout so that a similar command to the above line would work?

thanks

iceman47 08-15-2004 07:05 PM

A quick bash script:
Code:

#!/bin/bash
find <winxp mount point> -name *.txt > ~/list
for file in $(list)
do
cp $file ~
done
rm ~/list

chmod +x and execute

quentusrex 08-15-2004 07:09 PM

this is some good code. question: if I were to name it "Log_Finder". how would I enter the command:

Log_Finder school

and get it to find all files with any file name including 'school'

quentusrex 08-15-2004 07:45 PM

is there anyway to get it to quote the files?
I modified the script some and it is having trouble inputing the "Program Files" directory because of the space. do you know of any way I can get either the output of the find to be entered into the file in this format: "/mnt/blah/blah/Program Files/filename"

or is there a way to have the input from the file be piped into the cp command and have quotes attached to the front and back of the (here--->)/mnt/blah/blah/Program Files/filename(<--here) when it is inputed from the temp file?

#!/bin/bash
find /mnt/C -name school > listmine
chmod 777 listmine
for file in $(listmine)
do
cp $file /home/blah/logs/school
done
rm listmine

quentusrex 08-15-2004 10:07 PM

does anyone know how to send a command line option to a bash script? I feel dumb asking, but i've some how forgotten.... all i can remember is the DOS way to do it...

If I want the script "Log_backup" to save all logs to a certain directory how do I send the directory name to it?

in this format:

blah@blah ~$ ./Log_backup /home/blah/logbackups

???

thanks all.

crabboy 08-15-2004 10:38 PM

Please do not post the same thread in more than one forum. Picking the most relevant forum and posting it once there makes it easier for other members to help you and keeps the discussion all in one place.

http://www.linuxquestions.org/rules.php

Duplicate to:

http://www.linuxquestions.org/questi...hreadid=218031

XavierP 08-16-2004 04:42 AM

Closed as per above.


All times are GMT -5. The time now is 03:31 PM.