$mapfile  –  Mapping of files of the current directory

$mapfile contains a mapping of the files inside the current directory and allows for easy interaction with the files and their content.

Reading a value yields the content of the file. Modifying a value writes to the file. Unsetting a value removes the files on disk.

Examples

Print file content using $mapfile and then remove it
1
2
3
4
5
zmodload zsh/mapfile
echo -e "hello world\nbye" > test-file
echo "${mapfile[test-file]}"
unset "mapfile[test-file]"
  
Output:
1
2
hello world
bye
BashSupport Pro is a Zsh IDE with support for $mapfiletry it now!
© 2020–2024 Joachim Ansorg
Imprint
Privacy Policy
Legal