Jump to content
Aerosol

Ce ne facem cand avem de sters multe fisiere dintr-un director?

Recommended Posts

Posted

Poate ca unii vor spune rm -rf nume_director

Poate unii stiti ca in kernelul de unix, fie el Linux sau FreeBSD exista o limita pentru numarul de argumente pe care le poate primi o comanda. Astfel rm -rf * se traduce prin rm -rf fisier1 fisier2 … Foarte OK. Pana cand numarul de fisiere depaseste maximul numarului de argumente ce poate fi dat unei comenzi.

Eroarea care ne loveste e: rm: Argument list too long. (error code: 126).

Iata scriptul:

#!/bin/bash
rec(){
for I in `seq 0 9 `; do
echo $1$I
rm -rf ./$1$I*
[ $? -eq 126 ] && rec $1$I
done
}
rec 1198
EOF

Source

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...