I am trying to get 1:2:3:4:5:6:7:8:9:10 using parameter extension {1..10} and pattern matching:
1:2:3:4:5:6:7:8:9:10
{1..10}
$ var=$(echo {1..10}) $ echo ${var// /:} 1:2:3:4:5:6:7:8:9:10
Is there a more elegant way (single line) for this?
Agreeing with @choroba's comment on elegance, here are some other contemplative things:
# seq is a gnu core utility seq 1 10 | paste -sd: # Or: seq -s: 1 10 # {1..10} is bash-specific printf "%d\n" {1..10} | paste -sd: # posix compliant yes | head -n10 | grep -n . | cut -d: -f1 | paste -sd:
Elegance in the eye of the beholder:
( set {1..10} ; IFS=: ; echo "$*" )
Another possibility:
echo {1..9}: 10 | tr -d ' '
Source: https://habr.com/ru/post/945706/More articles:Calling a virtual function from the constructor - c ++https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/945702/adding-errors-to-model-in-rails-is-not-working&usg=ALkJrhjVVdV4xmVvmJArI2mCSCEEENVFsgManually call the @Scheduled method - javaMongo C ++ Client Library Doesn't See My Enhancement - c ++AWS responses from [i-2a7fe91f] were received, but commands were not executed - amazon-ec2https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/945707/hibernate-mysql-connection-timeouts-trying-to-deal-with-thread-pooled-executors-not-releasing-hibernate-connections-to-c3p0-after-exit&usg=ALkJrhiR8ct-2oGV2eDe9SD-aM5yG3s4MACompare the length of three lists in python - pythonUsing a while loop as an expectation in python - pythonhttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/945710/what-happens-to-local-functions-referenced-in-the-events-in-javascript&usg=ALkJrhhN3At2hoCkGOjLH8w8eEXbqW9SgQWhat is the difference between long and long in Android code? - javaAll Articles