https://github.com/ad1w/bash-doc
some tips on bash shell. Just a personal documentation
https://github.com/ad1w/bash-doc
bash bash-script shell shell-script
Last synced: about 1 month ago
JSON representation
some tips on bash shell. Just a personal documentation
- Host: GitHub
- URL: https://github.com/ad1w/bash-doc
- Owner: ad1w
- Created: 2025-07-03T13:53:45.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-08-01T14:23:00.000Z (11 months ago)
- Last Synced: 2025-10-28T23:39:16.019Z (8 months ago)
- Topics: bash, bash-script, shell, shell-script
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# BASH tips
Some tips on bash shell. Just a personal documentation
## Remove character
```
sed 's/character //'
```
for example:
```
~ $ cat text.txt
Cantarel Bold 14
to get "Cantarel 14" you can use:
~ $ cat text.txt | sed 's/Bold //'
Cantarel 14
```
## Get character separated by something
```
cut -d 'something' -f column
```
for example:
```
~ $ cat text.txt
gtk-font-name=Cantarel, 14
to get "Cantarel, 14" you can use:
~ $ cat text.txt | cut -d '=' -f 2
Cantarel, 14
```
## Get characters on a specific line
```
awk 'NR==linenumber'
```
for example:
```
~ $ cat text.txt
ABCD
EFGH
IJKL
to get "EFGH" you can use:
~ $ cat text.txt | awk 'NR==2'
EFGH
```
## Get characters on a specific column
```
awk '{print $numbercolumn}'
```
for example:
```
~ $ cat text.txt
ABCD EFGH IJKL
to get "EFGH" you can use:
~ $ cat text.txt | awk '{print $2}'
EFGH
```
## Add file or directory on bash script
```
export PATH="${PATH}:/location"
```
for example:
you want to add some files on your ```script``` directory, you can add this line in your bash script
```
#!/bin/bash
export PATH="${PATH}:/script"
```
## Print character on bash script
```
#!/bin/bash
cat <
```
for example, you can create a new file ```text.txt``` then you add this line:
```
#!/bin/bash
# Add colors
#normal
bla=$(tput setaf 0)
red=$(tput setaf 1)
gre=$(tput setaf 2)
yel=$(tput setaf 3)
blu=$(tput setaf 4)
mag=$(tput setaf 5)
cya=$(tput setaf 6)
whi=$(tput setaf 7)
#bright
bbla=$(tput setaf 8)
bred=$(tput setaf 9)
bgre=$(tput setaf 10)
byel=$(tput setaf 11)
bblu=$(tput setaf 12)
bmag=$(tput setaf 13)
bcya=$(tput setaf 14)
bwhi=$(tput setaf 15)
# Print result
cat <