如何从脚本中评论以下几行的每一行?
cat ${MYSQLDUMP} | \
sed '1d' | \
tr ",;" "\n" | \
sed -e 's/[asbi]:[0-9]*[:]*//g' -e '/^[{}]/d' -e 's/""//g' -e '/^"{/d' | \
sed -n -e '/^"/p' -e '/^print_value$/,/^option_id$/p' | \
sed -e '/^option_id/d' -e '/^print_value/d' -e 's/^"\(.*\)"$/\1/' | \
tr "\n" "," | \
sed -e 's/,\([0-9]*-[0-9]*-[0-9]*\)/\n\1/g' -e 's/,$//' | \
sed -e 's/^/"/g' -e 's/$/"/g' -e 's/,/","/g' >> ${CSV}
Run Code Online (Sandbox Code Playgroud)
如果我尝试添加评论说" cat $ {MYSQLDUMP} |\#Output MYSQLDUMP File ",我得到:
删除:未找到
是否有可能在这里发表评论,因为" __CODE__"?
快速背景:
$ ls src
file1 file2 dir1 dir2 dir3
Run Code Online (Sandbox Code Playgroud)
脚本:
#!/bin/bash
for i in src/* ; do
if [ -d "$i" ]; then
echo "$i"
fi
done
Run Code Online (Sandbox Code Playgroud)
输出:
src/dir1
src/dir2
src/dir3
Run Code Online (Sandbox Code Playgroud)
但是,我希望它阅读:
dir1
dir2
dir3
Run Code Online (Sandbox Code Playgroud)
现在我意识到我可以sed/awk输出删除"src /"但是我很想知道是否有更好的方法来解决这个问题.也许使用find + while-loop代替.
我有一个运行另一个bash脚本的bash脚本,但是第一个bashscript在继续之前没有等待第二个bashscript完成,我怎么能强迫它等待呢?
例如:
#!/bin/bash
# first.sh
#call to secondary script
sh second.sh
echo "second.sh has completed"
echo "continuing with the rest of first.sh..."
Run Code Online (Sandbox Code Playgroud)
它现在的方式,它将运行second.sh,并继续,而不必等待second.sh完成.
我发现了一个很棒的小程序,可以让我在我的Bash Scripts中添加用户友好的GUI;
然而,whiptail手册页并不是那么有用,也没有提供任何示例.在做了一些谷歌搜索后,我了解如何使用whiptail创建一个简单的是/否菜单:
#! /bin/bash
# http://archives.seul.org/seul/project/Feb-1998/msg00069.html
if (whiptail --title "PPP Configuration" --backtitle "Welcome to SEUL" --yesno "
Do you want to configure your PPP connection?" 10 40 )
then
echo -e "\nWell, you better get busy!\n"
elif (whiptail --title "PPP Configuration" --backtitle "Welcome to
SEUL" --yesno " Are you sure?" 7 40)
then
echo -e "\nGood, because I can't do that yet!\n"
else
echo -e "\nToo bad, I can't do that yet\n"
fi
Run Code Online (Sandbox Code Playgroud)
但我真的想建立一个文件选择菜单使用whiptail来替换我在一些不同的备份/恢复bash脚本中的旧代码:
#!/bin/bash
#This …Run Code Online (Sandbox Code Playgroud)