how split a string in bash?
January 12, 2008 7:21 PM Subscribe
using bash, i need to split a variable in two, on whitespace, but with just the first word in one variable, and the rest in the second variable. this is a one liner with perl. how in bash?
i have a properties file in the format:
variable (whitespace) value
values can include spaces, variables are always a single word. e.g.:
thisvar contents of this var
i need to extract 'thisvar' and 'contents of this var' as two strings.
in perl i'd do:
($first, $rest) = split (' ',$source)
how can i do this in a shell? (i.e. bash)
posted by jimjam to computers & internet (19 answers total) 5 users marked this as a favorite
posted by jepler at 7:31 PM on January 12, 2008