2

Hello everyone i want to know to cut the last field with separator : without knowing how many fields that i have any ideas please . is there any option for command cut .

Saif Marzougua
  • 33
  • 1
  • 1
  • 5

2 Answers2

4

You can revert the string and then print 1st character. Itself cut can't work from backwards.

echo "Your string ABC" | rev | cut -c 1
Milan Dufek
  • 164
  • 7
2

Awk is the right tool for this. Try :

ls -lh  | awk '{ print $NF }'
Matias Barrios
  • 4,123
  • 2
  • 15
  • 39