Find and replace in file and overwrite file doesn’t work, it empties the file

I would like to run a find and replace on an HTML file through the command line. My command looks something like this: sed -e s/STRING_TO_REPLACE/STRING_TO_REPLACE_IT/g index.html > index.html When I run this and look at the file afterward, it is empty. It deleted the contents of my file. When I run this after restoring … Read more

Using wget to recursively fetch a directory with arbitrary files in it

I have a web directory where I store some config files. I’d like to use wget to pull those files down and maintain their current structure. For instance, the remote directory looks like: http://mysite.com/configs/.vim/ .vim holds multiple files and directories. I want to replicate that on the client using wget. Can’t seem to find the … Read more

How to delete from a text file, all lines that contain a specific string?

How would I use sed to delete all lines in a text file that contain a specific string? 20 20 To remove the line and print the output to standard out: sed ‘/pattern to match/d’ ./infile To directly modify the file – does not work with BSD sed: sed -i ‘/pattern to match/d’ ./infile Same, … Read more

How do I copy a folder from remote to local using scp?

How do I copy a folder from remote to local host using scp? I use ssh to log in to my server. Then, I would like to copy the remote folder foo to local /home/user/Desktop. How do I achieve this? 12 scp -r [email protected]:/path/to/foo /home/user/Desktop/ By not including the trailing “https://stackoverflow.com/” at the end of … Read more