-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunix.txt
53 lines (39 loc) · 1.37 KB
/
unix.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
cp
==
cp file1 file2 creates file2 in the current directory that is a copy of file1.
cp file dir copies file into directory dir.
cp -R* dir copy recursively all into directory dir
cp -R dir1 dir2 copy recursively from dir1 to dir2
mv
==
mv old new renames old to new
mv -i old new to be prompted before overwriting, overwrite (y/n)?
mv old new renames old to new moves file into dir
find
====
find all files with .html extension in the current dir
find *.html
move all files in the current directory js (*js) to destination /var/www/js
find *js -exec mv {} /var/www/html/js \;
find all the file names that end with the .html file extension in the current dir denoted by (.)
find . -name \*.html -print
list all files whose names do not end in c
find / \! -name "*.c" -print
change directory permissions to 777 recursively
find /dir/here -type d -exec chmod 777 {} \;
change files permissions to 777 recursively
find /dir/here -type f -exec chmod 777 {} \;
grep
====
find "text" in dir/path recursively(r) and line-number(n)
grep -rn "text" dir/path
redirect output to file.txt
grep -r "text" dir/path > file.txt 2>&1
list files that start with 'a'
ls | grep '^a'
list files that end with '.gif'
ls | grep '.gif$'
list files alphabetically
ls | sort
list files alphabetically in reverse
ls | sort -r