Last active
February 14, 2019 07:11
-
-
Save mithildeeva/498c9c5dc21f65a5d154c121f11eb11d to your computer and use it in GitHub Desktop.
Important commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. scp command (SecureCoPy file/directory over ssh) | |
a. Copy from local to remote server | |
scp /absolute/path/on/local/to/file.txt <user>@<server-ip>:/absolute/path/to/file.txt | |
b. Copy from server to local | |
scp <user>@<server-ip>:/absolute/path/to/file.txt /absolute/path/on/local/to/file.txt | |
c. Copy directories (recursive) | |
scp -r <user>@<server-ip>:/absolute/path/to/directory/ /absolute/path/on/local/to/directory/ | |
2. sed command (Stream EDitor - to search/replace/delete in files) | |
a. Search and replace in file | |
sed -i 's=<string to search>=<string to replace with if the search string is found>gI' filename.ext | |
sed -i 's=/string/to/search=/string/to/replace=gI' *.ext | |
Here, | |
-i for performing operations In file | |
s means Search and replace | |
= is the delimiter (whatever follows s is assumed to be the delimiter. | |
Didn't use the most common '/' delimiter here since it is present in the search and replace strings | |
and adding escape characters in search strings makes them confusing) | |
g means to replace the searched string Globally and not just the first occurence | |
I means the search is case-insensitive. | |
b. Delete first/last line in file | |
sed -i '1d' filename.ext //deletes 1st line | |
sed -i '$d' filename.ext //deletes last line | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment