Create a script for PlayOnLinux - Chapter 6: The file system

Introduction

There are good means to manipulate your files in bash. We will give you the main commands

PlayOnLinux has a temporary folder

It's $HOME/.PlayOnLinux/tmp/

You can stock and modify the files you want inside of it.

it's recommanded to remove the files from this folder after their use

Changing of directory

You just need to use the cd command.
Note: The new directory is stocked in the $PWD variable

Example:

cd $HOME/.PlayOnLinux/tmp/

Some correspondences

./ corresponds to the current directory

../ corresponds to the parent directory

Removing a file or a directory

Beware, this command is very dangerous. I could destroy all your files if you don't manipulate it well. For example, if you decide to erase /home/tinou/.PlayOnLinux/tmp/ but you put a space between /tinou/ and .PlayOnLinux inadvertently, say goodbye to your documents. PlayOnLinux won't be responsible of a bad manipulation from yourself.

This being said, here are the codes

rm ./file.extension

Will remove file.extension in the current directory ($PWD)

rm ./folder -r

Removes the folder and its contents.

Copying a file from a directory to another

cp source_file target_directory

Copying a directory

cp source_directory target_directory/ -r

Moving or renaming a file or a directory

mv source_directory target_directory mv source_file target_file

Bonus: Reading a directory and sending the result in a PlayOnLinux menu

I give the code without explainning it. To understand it, see the annexes

cd $HOME/.PlayOnLinux/configurations/installed
variable=$(menu "Your choice:" "$(ls -1)" "" 0 0 0 "" "--cut-line")