[Shell] Argument list too long

As a Linux user, you may have to get the following error:

bash: /bin/rm: Argument list too long

There are a lot of methods to resolve this issue, but I use this stupid and simple one:

Here the code (copy, type vi rmany.shpaste the code):

[code lang=”bash” autolinks=”false” collapse=”false” firstline=”1″ gutter=”true” htmlscript=”false” light=”false” padlinenumbers=”false” smarttabs=”true” tabsize=”4″ toolbar=”false”]#
# rmany.sh
#  – List or delete a lot of files…
#    …specially in this folder!
#
# (c)apasca
#
#
#!/bin/bash
#
for X in *.$1
do
$2 "$X";
done
#
# FIRST:
#   chmod +x rmany.sh
#   alias rmany=’./rmany.sh’
#
# USAGE:
#   rmany [EXTENSION] [COMMAND]
#[/code]

You need to make it executable (chmod +x rmany.sh) and optionally add it as alias (alias rmany=’./rmany.sh’).

If you have created an alias you can type on console simply “rmany txt rm” and press enter!

Your input is rmany [EXTENSION] [COMMAND]

 

Alberto Pasca

Software engineer @ Pirelli & C. S.p.A. with a strong passion for mobile  development, security, and connected things.