0
Thanks

A few words of thanks would be greatly appreciated.

Shell – Convert character to Number



Issue


I made a small shell script in which thanks to commands: sort, cut, awk,
I could retrieve the largest GID group of my system, and saving it in a variable C.
I would like to increment this GID for other use, but the result is false.


If GID is returned is c = 5000, this is what I did next:
echo $ ((c +1))


but I get the result as "1".
I would therefore ask if the GID recovered is seen as a string?
If yes how can I do to convert people?

Solution



Hello you can use this:
[tmpfs]$ A=$(id -g)

[tmpfs]$ echo $A
500

[tmpfs]$ ((A++))

[tmpfs]$ echo $A
501

[tmpfs]$

Note


Thanks to jipicy for this tip on the forum.
0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
Related
This document, titled « Shell – Convert character to Number », is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!