Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using awk/cut in bash to strip space and get value

Tags:

bash

svn

I'm trying to get the value in the first column as shown below using awk or cut but I don't seem to get it.

  7  ?                    Jun 18 23:31 test3folder1/

I only need the number 7 in the above output to store in a variable. How do I do this? The above is the output of the "svn ls" command.

like image 856
Lego Avatar asked Nov 21 '25 10:11

Lego


1 Answers

awk '{print $1}'

'awk' strips by one or several consecutive delimiters (space in your case), while 'cut' always strips by single delimeter.

like image 85
timtofan Avatar answered Nov 23 '25 00:11

timtofan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!