How can I cut last "<" ? Here is my output :
#20 17 03 45 * root bash /media/data/loop.sh <
and this is my command
diff filecron filecrontmp | grep "<" | head -n 1
I just want #20 17 03 45 * root bash /media/data/loop.sh
for output. What command should I pipe again? I've try with xargs
but nothing happen.
You could try the below sed command,
$ echo '#20 17 03 45 * root bash /media/data/loop.sh <' | sed 's/ [^ ]*$//'
#20 17 03 45 * root bash /media/data/loop.sh
It would remove the last space and the following characters. So your command would be,
diff filecron filecrontmp | grep "<" | head -n 1 | sed 's/ [^ ]*$//'
Using BASH string manipulations:
s='#20 17 03 45 * root bash /media/data/loop.sh <'
echo "${s%<*}"
#20 17 03 45 * root bash /media/data/loop.sh
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.