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 set a variable to the output of a command in Bash?

I have a pretty simple script that is something like the following: #!/bin/bash VAR1=”$1″ MOREF=’sudo run command against $VAR1 | grep name | cut -c7-‘ echo $MOREF When I run this script from the command line and pass it the arguments, I am not getting any output. However, when I run the commands contained within … Read more

How do I split a string on a delimiter in Bash?

I have this string stored in a variable: IN=”[email protected];[email protected]” Now I would like to split the strings by ; delimiter so that I have: ADDR1=”[email protected]” ADDR2=”[email protected]” I don’t necessarily need the ADDR1 and ADDR2 variables. If they are elements of an array that’s even better. After suggestions from the answers below, I ended up with … 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