Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ranfdev/learn_bash
https://github.com/ranfdev/learn_bash
Last synced: 4 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/ranfdev/learn_bash
- Owner: ranfdev
- License: gpl-3.0
- Created: 2018-11-26T16:53:45.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-28T21:29:21.000Z (about 6 years ago)
- Last Synced: 2024-10-31T14:06:11.614Z (about 2 months ago)
- Size: 16.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# learn_bash
Here i will put some bash tips i have discovered. These are not only related to bash, but to the terminal in general.## shortcuts
| shortuct | action |
| ---------| -------|
| ctrl+a | start of the line |
| ctrl+e | end of the line |
| ctrl+u | cut from cursor to start |
| ctrl+y | paste what you have just cut |
| ctrl+r | search in history |
| ctrl+l | clear screen |## command substitution
to insert the result of a command as a parameter, put the command between two ticks ``` ` ``` or ```$()```
```
touch `date`
```## brace expansion
By putting some curly braces near an expression, you can combine the expression with the content of the braces
```
echo 1{1,2,3} {a,b,c}{a,b}
```
returns
```
11 12 13 aa ab ba bb ca cb
```## tar
- To create a tar archive:
```
tar -cf destination from_folder
```
- To create a tar archive from stdin:
```
random_program | tar -cf destination --null -T -
```
random_program should return a file list separated by null characters, to support names with \n or other escape sequences.
after tar, the flag --null enables reading that list of files. The option -T is used to describe where to get the list from. - is the stdin.## netcat
- to start listening for tcp connections on a port:
```
nc -l port_number
```
- to connect to a remote server which is listening for tcp connections:
```
nc ip port
```
After establishing a connection between two machines, everything you type in that terminal session,
is sent to the other device.
- send file to other device:
on the sender device:
```nc -l port < file_path```
on the receiver:
```nc ip port > file_path```
- show progress on the receiver
```nc ip port | pv > file_path```
where pv is a utility used to analyze a pipe, it shows the current speed and the bytes transfered.
## gpg
- basic file encryption:
```gpg -c file```
outputs the file as file.gpg, encrypted.
- basic file decryption:
```gpg -d file > dest```
## fzf
this is a must have. This program is a fuzzy search utility that can be integrated with various other programs.