xgqfrms / bash-all-in-one

linux bash
https://bash-all-in-one.xgqfrms.xyz
MIT License
1 stars 0 forks source link

bash echo 写文件 #5

Open xgqfrms opened 2 years ago

xgqfrms commented 2 years ago

bash echo 写文件


# 覆盖写
echo ipconfig getifaddr en0 > LocalIP
# 追加写
echo ipconfig getifaddr en0 >> LocalIP
xgqfrms commented 1 year ago

echo

#!/usr/bin/env bash

# echo \\n
echo -e '\n'

echo '$0'=$0
echo '$1'=$1

# echo -e '\n'
printf '\n'

# linux block comments / linux multi-lines comments

# ❌
echo <<EOF
Linux Here Documents
这个多行注释 1
这个多行注释 2
这个多行注释 3
EOF

# ✅
# cat <<EOF
# Linux Here Documents
# 这个多行注释 1
# 这个多行注释 2
# 这个多行注释 3
# EOF

# write 覆盖 >
echo 'hello world 1' > single_output.txt
echo 'hello world 2' > single_output.txt
# write 追加 >>
echo 'hello world 3' >> single_output.txt
echo -e '\n'

# write 覆盖 >
echo "hello world 1" > double_output.txt
echo "hello world 2" > double_output.txt
# write 追加 >>
echo "hello world 3" >> double_output.txt
echo -e '\n'

# clear
# rm -rf single_output.txt
# rm -rf double_output.txt

# var
echo 🅿️ "The path variable is $PATH"
echo -e '\n'

# *
echo 👻 *
echo 👻 *.sh
echo -e '\n'

# path
echo 🚀 ~
echo -e '\n'

# range
echo {1..7}
echo -e '\n'

# "" vs ''
echo ✅ "$(ls -al)"

echo ❌ '$(ls -al)'

echo 👎 $(ls -al)
echo -e '\n'

image