eg:
echo "abcdef_312345" | cut -b 9 --> output of this will be 1, so I want to increase that by 1 in the same line
echo "abcdef_312345" | cut -b 9 | <command to increment by 1>
eg:
echo "abcdef_312345" | cut -b 9 --> output of this will be 1, so I want to increase that by 1 in the same line
echo "abcdef_312345" | cut -b 9 | <command to increment by 1>
Eliminate the subprocess overhead:
$ x="abcdef_312456"
$ y=$(( ${x:8:1} + 1 ))
$ echo "${y}"
2
You can do :
echo "abcdef_312345" | cut -b 9 | awk '{print $1 + 1}'
But cut | awk is an anti-pattern, so you should do:
echo "abcdef_312345" | awk '{print $9 + 1}' FS=