How do Bash shell remove the first ie. earlier file/folder of list pattern with pairs of almost identical name such illustration;
(the real is not directly from ls but it's result from pipe)
note that parsing ls (by feeding it to xargs, or using a command substitution) is dangerous and easy to break: http://mywiki.wooledge.org/ParsingLs Command substitutions should almost always be quoted: http://mywiki.wooledge.org/Quotes. There's also no reason to use ls in this case. Just pass the glob directly to rm:
1 2 3 4 5 6 7 8 9
~/tmp λ touch aaa aab bba bbb bbc
~/tmp λ echo [ab]*
aaa aab bba bbb bbc
~/tmp λ rm -v [ab]*
aaa
aab
bba
bbb
bbc
edit: https://shellcheck.net is also a great resource if you're going to be writing shellscripts
Remove the first 17 files listed (with the above caveats on using xargs):
and the above (terribly dangerous and insecure) caveats of using ls in a pipeline. Seriously, it's better to just not use it, and there's almost no reason.
for X in aaa wyyy xyxxx aba aax bbc bbb
do echo ${X} | grep -E "${X:0:1}{3,3}"
done
X should be quoted. ${X} is exactly the same as $X here, and the {} portion does nothing to prevent wordsplitting http://mywiki.wooledge.org/Quotes.