Given a list of bash commands to manipulate folders/files. Can you answer the results of a list of existence checking?
existFolder path
Check whether a folder specified by path exists. Output ‘true’ if folder exists, ‘false’ otherwise.
Given a list of bash commands to manipulate folders/files. Can you answer the results of a list of existence checking?
The first line contains two integers m(1 m 1000) and n((1 n 100) – the number of commands and questions separately.The following m lines are the commands, followed by n lines of questions.
For each question, output “true” if the file/folder
exists or “false” otherwise.
4 2 mkdir -p a/b/c mkdir a/b/c/d/e touch file1 rm -r a/b existFolder /a/b existFile /file1
false true
1. We are in root folder ‘/’.
2. ‘/’ at the beginning of each path is optional.
3.Multiple sequential '/' is equal to one '/'.
4. The path string will only contain alphabetic characters, numbers, '_' or '/'.
5. Command options, -p and -r, will always occur before path string it they exist and there will only be one path string for each command.
NAME
mkdir -- make directories
SYNOPSIS
mkdir [-p] directory_name
DESCRIPTION
The mkdir utilitycreates the directories named as operands.
The options areas follows:
-p Create intermediatedirectories as required. If this optionis not specified, the full path prefix of each operand must already exist. On the other hand, with this optionspecified, no error will be reported if a directory given as an operand alreadyexists.
NAMEtouch -- change file access andmodification times
SYNOPSIS
touch file
DESCRIPTION
The touch utility sets themodification and access times of files. If any file does not exist, it is created with default permissions.
NAMErm -- remove directory entries
SYNOPSIS
rm [-r] file
DESCRIPTION
The rm utility attempts to remove the non-directory type filesspecified on the command line.
The options are as follows:
-r Attempt to remove the file hierarchyrooted in the file argument. The -roption implies the -d option.
这道题你会答吗?花几分钟告诉大家答案吧!