My Bash Commands
Resources:
1. Remove spaces from file and folder names and then remove numbers from files and folder names....
Description: need to : sudo apt install rename
sudo apt install renameNotes: Issue when renaming file without numbers collides with existing file name...
code:
find . -name "* *" -type d | rename 's/ /_/g'
find . -name "* *" -type f | rename 's/ /_/g'find $dir -type f | sed 's|\(.*/\)[^A-Z]*\([A-Z].*\)|mv \"&\" \"\1\2\"|' | sh
find $dir -type d | sed 's|\(.*/\)[^A-Z]*\([A-Z].*\)|mv \"&\" \"\1\2\"|' | sh
for i in *.html; do mv "$i" "${i%-*}.html"; done
for i in *.*; do mv "$i" "${i%-*}.${i##*.}"; doneDescription: combine the contents of every file in the contaning directory.
Notes: this includes the contents of the file it's self...
code:
2. Download Website Using Wget:
Description:
Notes: ==> sudo apt install wget
code:
3. Clean Out Messy Git Repo:
Description: recursively removes git related folders as well as internal use files / attributions in addition to empty folders
Notes: To clear up clutter in repositories that only get used on your local machine.
code:
4. clone all of a user's git repositories
Description: clone all of a user or organization's git repositories.
Notes:
code:
Generalized:
Clone all Git User
Clone all Git Organization:
5. Git Workflow
Description:
code:
6. Recursive Unzip In Place
Description: recursively unzips folders and then deletes the zip file by the same name.
Notes:
code:
7. git pull keeping local changes:
Description:
Notes:
code:
8. Prettier Code Formatter:
Description:
Notes:
code:
9. Pandoc
Description:
Notes:
code:
10. Gitpod Installs
Description:
Notes:
code:
11. Repo Utils Package:
Description: my standard repo utis package
Notes:
code:
12. Unix Tree Package Usage:
Description:
Notes:
code:
13. Find & Replace string in file & folder names recursively..
Description:
Notes:
code:
14. Remove double extensions :
Description:
Notes:
code:
15. Truncate folder names down to 12 characters:
Description:
Notes:
code:
16.Appendir.js
Description: combine the contents of every file in the contaning directory.
Notes: this includes the contents of the file it's self...
code:
17. Replace space in filename with underscore
Description: followed by replace '#' with '_' in directory name
'#' with '_' in directory nameNotes: Can be re-purposed to find and replace any set of strings in file or folder names.
code:
18. Filter & delete files by name and extension
Description:
Notes:
code:
19. Remove lines containing string:
Description:
Notes: Remove lines not containing
'.js'
code:
20. Remove duplicate lines from a text file
Description:
Notes: //...syntax of uniq...// $uniq [OPTION] [INPUT[OUTPUT]] The syntax of this is quite easy to understand. Here, INPUT refers to the input file in which repeated lines need to be filtered out and if INPUT isn’t specified then uniq reads from the standard input. OUTPUT refers to the output file in which you can store the filtered output generated by uniq command and as in case of INPUT if OUTPUT isn’t specified then uniq writes to the standard output.
Now, let’s understand the use of this with the help of an example. Suppose you have a text file named kt.txt which contains repeated lines that needs to be omitted. This can simply be done with uniq.
code:
21. Remove lines containing string:
Description:
Notes:
code:
22. Zip directory excluding .git and node_modules all the way down (Linux)
Description:
Notes:
code:
23. Delete files containing a certain string:
Description:
Notes:
code:
24.
Description:
Notes:
code:
25. Index of Iframes
Description: Creates an index.html file that contains all the files in the working directory or any of it's sub folders as iframes instead of anchor tags.
Notes: Useful Follow up Code:
code:
26. Filter Corrupted Git Repo For Troublesome File:
Description:
Notes:
code:
27. OVERWRITE LOCAL CHANGES:
Description:
Important: If you have any local changes, they will be lost. With or without --hard option, any local commits that haven't been pushed will be lost.[*] If you have any files that are not tracked by Git (e.g. uploaded user content), these files will not be affected.
Notes: First, run a fetch to update all origin/ refs to latest:
code:
28. Remove Submodules:
Description: To remove a submodule you need to:
Notes:
Delete the relevant section from the .gitmodules file. Stage the .gitmodules changes git add .gitmodules Delete the relevant section from .git/config. Run git rm --cached path_to_submodule (no trailing slash). Run rm -rf .git/modules/path_to_submodule (no trailing slash). Commit git commit -m "Removed submodule " Delete the now untracked submodule files rm -rf path_to_submodule
code:
29. GET GISTS
Description:
Notes:
code:
30. Remove Remote OriginL
Description:
Notes:
code:
31. just clone .git folder:
Description:
Notes:
code:
32. Undo recent pull request:
Description:
Notes:
code:
33. Lebab
Description: ES5 --> ES6
Notes:
code:
34. Troubleshoot Ubuntu Input/Output Error
Description: Open Powershell as Administrator...
Notes:
code:
35. Export Medium as Markdown
Description:
Notes:
code:
36. Delete files in violation of a given size range (100MB for git)
Description:
Notes:
code:
37. download all links of given file type
Description:
Notes:
code:
38. Kill all node processes
Description:
Notes:
code:
39. Remove string from file names recursively
Description: In the example below I am using this command to remove the string "-master" from all file names in the working directory and all of it's sub directories.
code:
Notes: The same could be done for folder names by changing the -type f flag (for file) to a -type d flag (for directory)
40. Remove spaces from file and folder names recursively
Description: replaces spaces in file and folder names with an _ underscore
_ underscoreNotes: need to run
sudo apt install renameto use this command
code:
41. Zip Each subdirectories in a given directory into their own zip file
Description:
Notes:
code:
42.
Description:
Notes:
code:
43.
Description:
Notes:
code:
44.
Description:
Notes:
code:
45.
Description:
Notes:
code:
46.
Description:
Notes:
code:
47.
Description:
Notes:
code:
48.
Description:
Notes:
code:
49.
Description:
Notes:
code:
50.
Description:
Notes:
code:
51.
Description:
Notes:
code:
52.
Description:
Notes:
code:
53.
Description:
Notes:
code:
54.
Description:
Notes:
code:
55.
Description:
Notes:
code:
56.
Description:
Notes:
code:
57.
Description:
Notes:
code:
58.
Description:
Notes:
code:
59.
Description:
Notes:
code:
60.
Description:
Notes:
code:
61.
Description:
Notes:
code:
62.
Description:
Notes:
code:
63.
Description:
Notes:
code:
64.
Description:
Notes:
code:
65.
Description:
Notes:
code:
66.
Description:
Notes:
code:
67.
Description:
Notes:
code:
68.
Description:
Notes:
code:
69.
Description:
Notes:
code:
70.
Description:
Notes:
code:
71.
Description:
Notes:
code:
72.
Description:
Notes:
code:
73.
Description:
Notes:
code:
74.
Description:
Notes:
code:
75.
Description:
Notes:
code:
76.
Description:
Notes:
code:
77.
Description:
Notes:
code:
78.
Description:
Notes:
code:
79.
Description:
Notes:
code:
80.
Description:
Notes:
code:
81.
Description:
Notes:
code:
82.
Description:
Notes:
code:
83.
Description:
Notes:
code:
84.
Description:
Notes:
code:
85.
Description:
Notes:
code:
86.
Description:
Notes:
code:
87.
Description:
Notes:
code:
88.
Description:
Notes:
code:
89.
Description:
Notes:
code:
90.
Description:
Notes:
code:
91. Unzip PowerShell
Description:
Notes:
code:
92. return to bash from zsh
Description:
Notes:
code:
93. Symbolic Link
Description: to working directory
Notes:
code:
94. auto generate readme
Description: rename existing readme to blueprint.md
Notes:
code:
95. Log into postgres:
Description:
Notes:
code:
96. URL To Subscribe To YouTube Channel
Description:
Notes:
code:
97. Embed Repl.it In Medium Post:
code:
98.
Description:
Notes:
code:
99. Cheat Sheet
Description:
Notes:
code:
Last updated
Was this helpful?