Tag Info

New answers tagged

3

I assume you're not describing your real-world scenario: not only do you want to copy hundreds of thousands of files, but you want to sleep for hundreds of thousands of seconds... wtf?!? Anyway: while IFS= read -r file1 IFS= read -r file2 do cp "$file1" "${file1##*/}-backup" cp "$file2" "${file2##*/}-backup" sleep 1 done < inputFile


1

Sorry: I have not noticed the "txt file" with the "hundreds thousands of lines". This is just a naif solution... for a in test*; do ls -l $a; if [[ $((i++ % 2)) != 0 ]]; then sleep 1; fi; done Update: Explanation and (partially update to txt file with filenames). ...reformating: for a in `cat file.txt` do cp "$a" "$a-backup" ## REPLACE ...


1

How about (notice the backslashes, all important): echo brew\ {install,update,doctor}\;| bash the first pattern (arguments for echo) will expand thusly: echo brew install; brew update; brew doctor; which is then echoed, producing this output: brew install; brew update; brew doctor; which we pipe to a new bash instance.


5

xargs seems to be what you want: echo install update doctor | xargs -n1 brew


1

Escape the first space and remove the other spaces: $ printf "'%s'\n" brew\ {install,update,doctor} 'brew install' 'brew update' 'brew doctor' If brew is a command just write (also without the spaces): brew {install,update,doctor} like with your mkdir example: mkdir {install,update,doctor} You need no external process or piping to do that; all can ...


2

Well, the Utility Sintax Guideline can answer your question about the order of the options, and it's relationship with other options: Guideline 11: The order of different options relative to one another should not matter, unless the options are documented as mutually-exclusive and such an option is documented to override any incompatible ...


0

The right thing so use is process substitution. wkhtmltopdf --title "$SUBJECT" -q <(command_with_output_stream) $OUTPUTFILE


0

guessing from comment, you seems to be able to do it with a temporary file, why not make a named pipe ? mknod magritte p inside you php code, just write to magritte. wkhtmltopdf should be run with /usr/local/bin/wkhtmltopdf --title "$SUBJECT" -q magritte $OUTPUTFILE you might specify the location more accurately. Still guessing, wkhtmltopdf is run ...


0

to make a program that opens a file by name read from the pipeline give it the special device name /dev/stdin ... for example: /usr/local/bin/program-to-output-the-html | /usr/local/bin/wkhtmltopdf --title "$SUBJECT" -q /dev/stdin $OUTPUTFILE or do this before the command you showed: SOURCEFILE=/dev/stdin then the program will open("/dev/stdin",...) ...


1

You should be able to do this using /dev/stdin and PHP's proc_open(). Start the process with a command such as wkhtmltopdf --title "$SUBJECT" -q /dev/stdin $OUTPUTFILE and pipe the HTML you've got in your variable into the running process.


2

With GNU xargs, you can use -d option: $ echo 1 2 3 4 5 | xargs -n 1 -d" " -I FOO echo FOO 1 2 3 4 5


2

First, your current script breaks on file names containing whitespace and other special characters. It's very easy to fix this: always use double quotes around variable substitutions, and use -exec instead of parsing the output of find. See Why does my shell script choke on whitespace or other special characters? for more information. find . -name "*.mkv" ...



Top 50 recent answers are included