foo@bar:~$ ls -1 <path to src folder> | sed -z 's/\n/ \\\n/g'
ft_atoi.c \
ft_bzero.c \
ft_calloc.c \
...
download release builds from github using curl and wget 5
curl -s https://api.github.com/repos/<ogranization-name>/<repo-name>/releases/latest \
| grep "browser_download_url.*zip" \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -qi -
show sorted used space 6
foo@bar:~$ du -h <folder path> | sort -h
3.2M ./libs/glfw/docs/html
5.5M ./libs/glfw
15M ./libs/glm/doc/api
18M ./libs/glm/doc
23M ./libs/glm
35M ./libs
39M .
foo@bar:~$ du -sh -- * | sort -h
36K LICENSE
288K include
536K template
764K assets
35M libs
create folder in each subfolder 7
for dir in */; do mkdir -- "$dir/<folder-name>"; done
Grep8
foo@bar:~$ grep -HEn '^SRCS' Makefile
Makefile:26:SRCS := ft_strlen.cpp
Useful when need to find match and quickly open in code editor
foo@bar:~$ grep -HEn 'main' src/main.cpp | awk -F: '{print $1":"$2" "$3}'
src/main.cpp:3 int main(int ac, char **av)
Perl9
foo@bar:~$ perl -ne 'print if /^SRCS/' Makefile
SRCS := ft_strlen.cpp
:%s/<match>/<replace>/g
Backreference: \0 or &
Footnotes
-
https://superuser.com/questions/951905/is-there-a-way-to-echo-a-blackslash-followed-by-newline-in-bash ↩
-
https://stackoverflow.com/questions/27658675/how-to-remove-last-n-characters-from-a-string-in-bash ↩
-
https://stackoverflow.com/questions/30993056/get-full-path-to-file-from-argument ↩
-
https://askubuntu.com/questions/1400937/how-can-i-get-the-path-of-directory-in-which-the-command-is-running ↩
-
https://gist.github.com/steinwaywhw/a4cd19cda655b8249d908261a62687f8 ↩
-
https://unix.stackexchange.com/questions/4681/how-do-you-sort-du-output-by-size ↩
-
https://unix.stackexchange.com/questions/61907/how-do-i-create-a-directory-in-all-subdirectories ↩
-
https://stackoverflow.com/questions/8105685/show-filename-and-line-number-in-grep-output ↩