小编Laz*_*tra的帖子

在Bash中解析MySQL输出

如何将表边框的mysql查询输出重定向为分隔符?我尝试使用此代码:

mysql -u root -h localhost -D cronjob -e "select * from cron_list" > query.txt
Run Code Online (Sandbox Code Playgroud)

我期望输出如下:

| id |  datetime  | recurrency |          command          |
|  1 | 2014-10-10 |    daily   | bash /media/data/daily.sh |
|  2 | 2014-10-09 |  minutely  |           conky           |
Run Code Online (Sandbox Code Playgroud)

但是,当我使用该代码时,它会给我输出

 id   datetime   recurrency           command          
  1  2014-10-10     daily    bash /media/data/daily.sh 
  2  2014-10-09   minutely             conky           
Run Code Online (Sandbox Code Playgroud)

那么,如何将终端的输出重定向到带终端的分隔符的文件?抱歉英文不好

mysql bash

6
推荐指数
1
解决办法
4025
查看次数

可以猛击grep"*"而不是"\*"吗?

如何*在文本文件中grep星号?这是我的代码:

if grep -F "\#$minute $hour $date $month $day $cr_user $comm" filecron; then
        echo "$minute $hour $date $month $day $cr_user $comm" > /dev/null 2>&1
        echo "data exist"

elif [[ -z $minute || -z $hour ]]; then
        echo "#$minute $hour $date $month $day $cr_user $comm" > /dev/null 2>&1
        echo "nothing to input"
        echo "" >> filecron

elif [[ $stat == "inactive" ]]; then
        echo "\#$minute $hour $date $month $day $cr_user $comm" >> filecron
        echo "input data inactive to filecron" …
Run Code Online (Sandbox Code Playgroud)

bash

4
推荐指数
1
解决办法
102
查看次数

Bash:grep 独特的行

我想要grep独特的路线。这是文件内容:

this is line 1
this is line 1
this is line 2
this is line 1
this is line 1
Run Code Online (Sandbox Code Playgroud)

我只想输出this is line 2到我的外壳。我怎样才能做到这一点?

bash grep uniq

-1
推荐指数
2
解决办法
1万
查看次数

标签 统计

bash ×3

grep ×1

mysql ×1

uniq ×1