Replace text using sed/awk

Category: /knowledge /linux
Tags: linux

use sed to remove leading and trailing spaces

echo $var | sed -e 's/^ *//g' -e 's/ *$//g'

another simple solution is

echo $var | xargs

get the last day of the month

cal "${month}" "${year}" | sed '/^[ \t]*$/d' | tail -1 \
| sed 's/^.* //'

replace a string in a file with sed

sed -ie 's/string_1/string_2/g' *.jsp

评论

提示

  • 如果看不到评论部分, 请暂时关掉adblock in Firefox/Chrome
  • 本网站使用Javascript实现评论功能, 此处外链对提高您的网站PR没有帮助. (潜台词: 请不要灌水, 谢谢)