有一个小的bash脚本,如下所示
Entry present in conf file ($D--- is missing)
it should be Subsystem sftp /usr/libexec/openssh/sftp-server #### ####
但输出如下所示
<resources>
<!-- Base application theme. -->
<style name="AppTheme"parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimaryDark">@color/statusBarColor</item>
<item name="colorPrimary">@color/toolBarHeaderColor</item>
<item name="android:windowTranslucentStatus">false</item>
</style>
<style name="ThemeToolbar" parent="Theme.AppCompat.Light">
<item name="android:homeAsUpIndicator">@drawable/icon_add_fm</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
</resources>
有没有办法显示$ D of match box ???
答案 0 :(得分:0)
我认为这就是你在这个问题上想要实现的目标。
只需将C
更改为您要搜索的字符串即可。
#!/bin/bash
CONF_FILE="/etc/ssh/sshd_config" # the file to search
C="Port 22" # The string you want to find
RESULTS=$(grep "$C" $CONF_FILE) # The grep result
LINES_FOUND=$(echo $RESULTS | wc -l) # How many lines contain C in CONF_FILE
if [ $LINES_FOUND -eq 0 ]; then # File does not contain C
echo "Entry not present in conf file $CONF_FILE"
echo ""
echo -e "it should be \t\t\t$C"
else # At least one line matches
echo "Entry is proper in $CONF_FILE"
fi