bash: remove files interactively
2019-02-23 2019-12-30 00:22:41


Q: How to remove files interactively so that one is prompted for each file before the final deletion.

A: use the rm command with the -i option.

remove interactively all files which match Pattern "*_160x120"

rm -i *_160x120


admin1@erazer:/tmp$ rm -i *_160x120
rm: Normale Datei 'bild029.f15a3c6ded0213f91604e90830a3f902.jpg_160x120' entfernen? j
rm: Normale Datei 'bild036.3df230bc879330b8084f11b45cca3aa8.jpg_160x120' entfernen?  […]

bash: read File into Array
2019-01-13 2019-12-30 00:22:22


Q: how to read a file into array with bash?

A: use mapfile


// file to read

// create array `aMimeType`
mapfile aMimeType < <(cat "$sMimeTypeList" | grep -v "^$");

// test outputs
echo "${aMimeType[@]}";         # all
echo "100: ${aMimeType[100]}";  # just the 100. entry
~~~ […]

This website uses Cookies to provide you with the best possible service. Please see our Privacy Policy for more information. Click the check box below to accept cookies. Then confirm with a click on "Save".