Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
So this command will replace abc with XYZ in file.txt in directory tmp
sed -ie 's/abc/XYZ/g' /tmp/file.txt
How do you do a find and replace like this across a large number of files in a directory with a .html extension in one go?
find /start/path -name *.html -exec sed -ie 's/abc/XYZ/g' '{}' \;
As by your request, here is what it does:
find /start/path -name *.html
Finds all files that glob to *.html, starting in /start/path
The -exec option tells find, to not just print out the files, but to run a command on them. Inside this command {} is replaced by the file. The -exec option hast to end with a semicolon, which we have to escape with a backslash, else bash will swallow it.
Again, from the OP's special situation: Put the following into a file called replaceabc.sh
#!/bin/bash
find '/home/129224/domains/sandpit.uk-cpi.com/html/sshit' -name '*.html' -exec sed -ie 's/abc/XYZ/g' '{}' \;
then from the shell prompt
chmod 700 /path/to/replaceabc.sh
/path/to/replaceabc.sh
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
I need to programmatically execute long running script on a remote server. I tried to use ssh with screen or tmux and so far I could not make it work.
With tmux I managed to make it work when typing the ssh command from my local machine terminal:
ssh <server_name> -t -t tmux new -s my_session \; set-buffer "bash my_script.sh" \; paste-buffer \; send-keys C-m \; detach
But if I run this programmatically I get this error:
open terminal failed: missing or unsuitable terminal: unknown
Connection to <server_name> closed
Use the -d flag to new-session to start tmux detached. So:
ssh <server_name> tmux new -ds my_session \; send-keys "bash my_script.sh" C-m
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I wanted to generate a showroom page for my jupyter notebooks using a continuous integration tool like Travis.
A perfect example is Shogun's showroom page but I don't know what they are using.
we are using buildbot to generate it; here's the job for it:
http://buildbot.shogun-toolbox.org/builders/nightly_default/builds/44
the content of the generate notebook is pretty straightforward:
#!/bin/bash
export PYTHONPATH=$PWD/build_install/lib/python2.7/dist-packages:$PYTHONPATH
export LD_LIBRARY_PATH=$PWD/build_install/lib:$LD_LIBRARY_PATH
find $1 -type f \( -name '*.ipynb' ! -name 'template.ipynb' \) | xargs -I{} cp '{}' $3
find $1 -type f \( -name '*.ipynb' ! -name 'template.ipynb' \) | xargs -P $2 -I{} jupyter nbconvert --ExecutePreprocessor.timeout=600 --to html --output-dir $3 --execute '{}'
find $3 -type f -name '*.html' | xargs -P $2 -I{} python extract_image_from_html.py '{}'
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I am currently in public_html dir and when executing
rm filename.php
it removes only that file in public_html dir ,
but in over 80 sub dirs I have and also need to remove the same file .
What would command be for that?
Assuming the fully qualified name of the directory, how about:
find /var/public_html -name "filename.php" -exec rm -rf {} \;
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm trying to get into tar file the stdout generated from Mysqldump:
mdm#deb606:~$ mysqldump --opt test1 -u root -ppassword | tar -czf example.tar.gz
doesn't work.
At the moment I've temporary solved using:
mdm#deb606:~$ mysqldump --opt test1 -u root -ppassword | gzip -f > example.gz
Is it possible do the the same using also tar or bzip2?
I don't know that it's possible to pipe directly into tar (in general, that doesn't make a lot of sense), however the bzip2 command will accept - to mean to read from stdin, i.e.:
mdm#deb606:~$ mysqldump --opt test1 -u root -ppassword | bzip2 - > example.bz2
I am trying to write a simple command that searches through a music directory for all files of a certain type and copies them to a new directory. I would be fine if the files didn't have spaces.
I'm using a script from the following question, but it fails for spaces:
bash script problem, find , mv tilde files created by gedit
Any suggestions on how I can handle spaces, once I'm satisfied that all the files are being listed, I'll change echo to cp
for D in `find . -name "*.wma*"`; do echo "${D}"; done
You probably want to do this instead:
find . -name *.wma -exec echo "{}" \;