https://swcarpentry.github.io/shell-novice/03-create.html
$ mkdir folderName
Make directory in the current working directory.
$
mkdir-p ../project/data ../project/result
-p = allows mkdir to create a directory with a nested subdirectories in a single operation
$ ls -FR ../project
-R = list all nested subdirectories within a directory
$ cd folderName
$
nanodraft.txt
nano = a text editor that only work with plain character data (no tables or images)
$
touchmy_file.txt
generates new empty file (to be used in other programs which require empty files have already been generated)
$
mvthesis/draft.txt thesis/quotes.txt
mv = ‘moving’, draft.txt를 quote.txt에 덮어씌우고 원 파일은 삭제됨
(경고없이 바로 삭제되므로 주의 요)
mv -i (or mv -interactive)는 덮어씌우기 전 한번 물어봐줌.
$
mvthesis/quotes.text .
quotes.txt를 . 로 옮김 (=current working directory!!)
$
cpquotes.txt quotations.txt
quotes 파일을 quotations라는 새로운 파일로 복사.
결과적으로 같은 파일이 두 개 생김.
$ mkdir quote_backup
$ cp quotes.txt quotations.txt quote_backup/
두 파일을 quote_backup 폴더로 복사
$ cp 1.txt 2.txt 3.txt
→ error cp: target 3.txt is not a directory
$ cp
-rthesis thesis_backup
To copy a directory, add the recursive option -r option.
*
*.pdb represents ethane.pdb propane.pdb ... every file ends with '.pdb'
p*.pdb represents pentane.pdb propane.pdb ...
?
It represents exactly one character.
?ethane.pad could represent methane.pdb
whereas *ethane.pdb represents both ethan.pdb, methane.pdb
???ane.pdb = cubane.pdb ethane.pdb octane.pdb
$ rm quote.txt
Removes the file.
❗️ DELETING IS FOREVER: The Unix shell doesn’t have a trash bin. No recovery.
Tools for finding and recovering deleted files do exit, but there’s no guarantee they’ll work in any particular situation.
$ rm -i
-i prompts warning for safe removal.
$ rm -r thesis
By adding -r, we can remove a directory and all its contents.
To be safe, use rm -r -i.