Last active
July 5, 2023 00:35
-
-
Save Lucent/86567af89db57ed45a7c01190f78fd27 to your computer and use it in GitHub Desktop.
Useful bash one-liners
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
# Remove all empty folders | |
find . -maxdepth 1 -type d -empty -print0 > empty.txt; xargs -0 rmdir < empty.txt | |
# Remove empty folders 2 levels deep, and their parent | |
find . -maxdepth 2 -type d -empty > empty.txt; rmdir $(<empty.txt) | |
find . -maxdepth 1 -type d -empty > empty.txt; rmdir $(<empty.txt) | |
# Move all folders with certain name into their own named folder | |
find -maxdepth 2 -name 'lavajava' -printf '%h\n' > lavajava.txt; mkdir lavajava; mv $(<lavajava.txt) lavajava/ | |
# Move root dir files in subdirs into a root folder | |
find -maxdepth 2 -type f -printf '%h\n' > files.txt; mv $(<files.txt) root/ | |
# Sort Trillian XML chat log by time | |
sed -r 's/^.*time="([^"]+)".*$/\1 &/' newfile.xml|sort -n|sed 's/[^ ]* //' | |
# Rename Samsung Voice recorder files to prefix their Media Create date | |
exiftool '-FileName<CreateDate' -d "%Y%m%d_%H%M%S %%f.%%e" -api QuickTimeUTC=1 *.m4a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment