Unix - kdaisho/Blog GitHub Wiki
Fold
Wraps input text to a specified width.
git log | fold -sw 5 | head -n 10
# commit
# a50a50f989
# d3fae6288d
# dc9115d094
# a9d8d2e32f
# Author:
# Daisho
# Komiyama
# <daishokom
# iyama@gmai
-s: Break lines at spaces whenever possible (soft wrapping). Without this, fold might split a word in the middle.
List in 1 column
ls -1
# output
README.md
apps
docker-compose.yml
node_modules
package.json
...
Backticks, Parenthesis
echo `date`
# output
Wed Nov 27 21:04:41 EST 2024
echo $(date)
# output
Wed Nov 27 21:04:41 EST 2024
echo some long data > blah-`date +%F`.log # or blah-$(date +%F).log
# creates a file with the content
blah-2024-11-27.log