User Tools

Site Tools


wiki:cpmv

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
wiki:cpmv [2015/11/11 10:40]
asa
wiki:cpmv [2016/08/02 14:47] (current)
Line 1: Line 1:
-==== Moving and copying files and directories (chapter 4) ====+===== Moving and copying files and directories (chapter 4) =====
  
 First, go into the ''​cs580''​ directory we created last time. First, go into the ''​cs580''​ directory we created last time.
Line 9: Line 9:
 </​code>​ </​code>​
 Type some stuff and then save the file and exit the program. Type some stuff and then save the file and exit the program.
 +
 +We can view the contents of the file without having to invoke the editor by using the ''​more''​ or ''​less''​ commands:
 +<code bash>
 +$ more my_new_file.txt
 +</​code>​
 +Note that ''​less''​ is more powerful than ''​more''​ and has a few additional features.
  
 Now, to demonstrate why it's not a good idea to use spaces in file names, try the following: Now, to demonstrate why it's not a good idea to use spaces in file names, try the following:
Line 83: Line 89:
 $ rm -R copy_of_cs580 $ rm -R copy_of_cs580
 </​code>​ </​code>​
-Be very careful with "​rm"​. ​ Linux does not have a way of undoing its action.+Be very careful with "​rm"​. ​ Linux does not have a way of undoing its action. ​ As a way of addressing that, it is not a bad idea to use the -i option of rm, which will ask you to verify each removed file/​directory. ​ It can be combined with other options, e.g.: 
 +<code bash> 
 +$ rm -Ri copy_of_cs580 
 +</​code>​
  
 === Renaming/​moving files/​directories === === Renaming/​moving files/​directories ===
Line 126: Line 135:
 </​code>​ </​code>​
 will copy all the files from ''​directory1''​ to ''​directory2''​. will copy all the files from ''​directory1''​ to ''​directory2''​.
 +
 +There are many more wild cards that are recognized. ​ For example ''?''​ matches a single character, so ''​data???''​ will match file names that start with data and are followed by any three characters. ​ Chapter 4 of the book provides more information on this topic.
  
 Be especially careful when using wildcards with ''​rm'':​ first use the ''​ls''​ command with the wildcard to verify which files will be affected. Be especially careful when using wildcards with ''​rm'':​ first use the ''​ls''​ command with the wildcard to verify which files will be affected.
wiki/cpmv.1447263644.txt.gz · Last modified: 2016/08/02 14:47 (external edit)