I have received a task to do these commands on a text file:
- Choose each second field from the file
- Sort and choose first 3 unique
- Print the contents of each
value.textwhile redirecting stderr
The thing I've come with is
cut cities.txt -f1 | sort| uniq | head -3 | xargs rename "s/*/*.text/" * | xargs cat 2>error.txt
but this gives an error:
Quantifier follows nothing in regex; marked by <-- HERE in m/* <-- HERE / at (user-supplied code).
I also tried to do it with
mv * *.text, but it doesn't work, saying
mv: target 'Germany' is not a directory, with "Germany" being the last value in the list of
Either of these commands is fine with me, but explaining why both of them do not work (and how to make them work) would be more appreciated.