5 deleted 1 character in body
source | link

Try to use:

grep "$(date +'%Y')" file.csv | tail -1 | sed 's/.*\(..$\)/\1/'

You don't need cat because grep can get data both from output of another program andor from certain file. The last method more efficient because it uses only one command and this is more fast and consume less system resources.

The full solution:

ytd_wk=$(grep "$(date +'%Y')" file.csv | tail -1 | sed 's/.*\(..$\)/\1/')

You can omit tail with GNU sed '$!d':

grep "$(date +'%Y')" file.csv | sed -r '$!d;s/.*(..$)/\1/'

POSIX:

grep "$(date +'%Y')" file.csv | sed -e '$!d' -e 's/.*\(..$\)/\1/'

Try to use:

grep "$(date +'%Y')" file.csv | tail -1 | sed 's/.*\(..$\)/\1/'

You don't need cat because grep can get data both from output of another program and from certain file. The last method more efficient because it uses only one command and this is more fast and consume less system resources.

The full solution:

ytd_wk=$(grep "$(date +'%Y')" file.csv | tail -1 | sed 's/.*\(..$\)/\1/')

You can omit tail with GNU sed '$!d':

grep "$(date +'%Y')" file.csv | sed -r '$!d;s/.*(..$)/\1/'

POSIX:

grep "$(date +'%Y')" file.csv | sed -e '$!d' -e 's/.*\(..$\)/\1/'

Try to use:

grep "$(date +'%Y')" file.csv | tail -1 | sed 's/.*\(..$\)/\1/'

You don't need cat because grep can get data both from output of another program or from certain file. The last method more efficient because it uses only one command and this is more fast and consume less system resources.

The full solution:

ytd_wk=$(grep "$(date +'%Y')" file.csv | tail -1 | sed 's/.*\(..$\)/\1/')

You can omit tail with GNU sed '$!d':

grep "$(date +'%Y')" file.csv | sed -r '$!d;s/.*(..$)/\1/'

POSIX:

grep "$(date +'%Y')" file.csv | sed -e '$!d' -e 's/.*\(..$\)/\1/'
4 added 232 characters in body
source | link

Try to use:

grep "$(date +'%Y')" file.csv | tail -1 | sed 's/.*\(..$\)/\1/'

You don't need cat because grep can get data both from output of another program and from certain file. The last method more efficient because it uses only one command and this is more fast and consume less system resources.

The full solution:

ytd_wk=$(grep "$(date +'%Y')" file.csv | tail -1 | sed 's/.*\(..$\)/\1/')

You can omit tail with GNU sed '$!d':

grep "$(date +'%Y')" file.csv | sed -r '$!d;s/.*(..$)/\1/'

POSIX:

grep "$(date +'%Y')" file.csv | sed -e '$!d' -e 's/.*\(..$\)/\1/'

Try to use:

grep "$(date +'%Y')" file.csv | tail -1 | sed 's/.*\(..$\)/\1/'

The full solution:

ytd_wk=$(grep "$(date +'%Y')" file.csv | tail -1 | sed 's/.*\(..$\)/\1/')

You can omit tail with GNU sed '$!d':

grep "$(date +'%Y')" file.csv | sed -r '$!d;s/.*(..$)/\1/'

POSIX:

grep "$(date +'%Y')" file.csv | sed -e '$!d' -e 's/.*\(..$\)/\1/'

Try to use:

grep "$(date +'%Y')" file.csv | tail -1 | sed 's/.*\(..$\)/\1/'

You don't need cat because grep can get data both from output of another program and from certain file. The last method more efficient because it uses only one command and this is more fast and consume less system resources.

The full solution:

ytd_wk=$(grep "$(date +'%Y')" file.csv | tail -1 | sed 's/.*\(..$\)/\1/')

You can omit tail with GNU sed '$!d':

grep "$(date +'%Y')" file.csv | sed -r '$!d;s/.*(..$)/\1/'

POSIX:

grep "$(date +'%Y')" file.csv | sed -e '$!d' -e 's/.*\(..$\)/\1/'
3 added 8 characters in body
source | link

Try to use:

grep $"$(date +'%Y')" file.csv | tail -1 | sed 's/.*\(..$\)/\1/'

The full solution:

ytd_wk=$(grep $"$(date +'%Y')" file.csv | tail -1 | sed 's/.*\(..$\)/\1/')

You can omit tail with GNU sed '$!d':

grep $"$(date +'%Y')" file.csv | sed -r '$!d;s/.*(..$)/\1/'

POSIX:

grep $"$(date +'%Y')" file.csv | sed -e '$!d' -e 's/.*\(..$\)/\1/'

Try to use:

grep $(date +'%Y') file.csv | tail -1 | sed 's/.*\(..$\)/\1/'

The full solution:

ytd_wk=$(grep $(date +'%Y') file.csv | tail -1 | sed 's/.*\(..$\)/\1/')

You can omit tail with GNU sed '$!d':

grep $(date +'%Y') file.csv | sed -r '$!d;s/.*(..$)/\1/'

POSIX:

grep $(date +'%Y') file.csv | sed -e '$!d' -e 's/.*\(..$\)/\1/'

Try to use:

grep "$(date +'%Y')" file.csv | tail -1 | sed 's/.*\(..$\)/\1/'

The full solution:

ytd_wk=$(grep "$(date +'%Y')" file.csv | tail -1 | sed 's/.*\(..$\)/\1/')

You can omit tail with GNU sed '$!d':

grep "$(date +'%Y')" file.csv | sed -r '$!d;s/.*(..$)/\1/'

POSIX:

grep "$(date +'%Y')" file.csv | sed -e '$!d' -e 's/.*\(..$\)/\1/'
2 added 2 characters in body
source | link
1
source | link