bash: remove files interactively
2019-02-23
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
example
admin1@erazer:/tmp$ rm -i *_160x120
rm: Normale Datei 'bild029.f15a3c6ded0213f […]
bash: read File into Array
2019-01-13
Q: how to read a file into array with bash?
A: use mapfile
example
// file to read
sMimeTypeList="/etc/mime.types";
// create array `aMimeType`
mapfile aMimeType < <(cat "$sMimeTypeList" | grep -v "^$");
// test outputs
echo "${aMimeType[@]}"; # all
echo "100: ${aMimeType[100]}"; # just the 100. entry
[…]