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.
Lonely Integer - Bash!
Lonely Integer - Bash!
Sort by
recency
|
195 Discussions
|
Please Login in order to post a comment
tr " " "\n" | tail +2 | sort | uniq -u
tr is used so each array element in new line for further processing tail is used to skip 1st line which contain total no. of array elements sort for uniq cmd to work as desired uniq -u print only the uniq elementin case if you don't want to use sort | uniq etc. for some reason:
read n
mapfile -t arr
arr=({arr[@]}" | tr ' ' '\n' | sort -n | uniq -u))
echo "${arr[@]}"