We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
$( ) is for command subsitution, it moves output of cat command to an array.
In here :
# $(cat) == $(cat $1)
cause the input is a file and you should use cat to get the file contents.
for example for defining an array from all the files in the current directory, you can use this:
arr=($(ls .))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Filter an Array with Patterns
You are viewing a single comment's thread. Return to all comments →
$( )
is for command subsitution, it moves output ofcat
command to an array. In here :# $(cat) == $(cat $1)
cause the input is a file and you should use
cat
to get the file contents. for example for defining an array from all the files in the current directory, you can use this:arr=($(ls .))