Terminal - Files Flashcards

1
Q

Find files which have been modified today

A

find . -mtime -1 -print

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Find all backup files in a directory

A

find . -name *~ -print

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Find all backup files and delete them!

A

find . -name “*~” -exec rm {} \;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Change permissions for all folders only

A

find . -type d -exec chmod g+x {} \;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Set the group id bit (so files created later in the folder belong to the folder’s group)

A

chmod g+s directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Uncompress lots of zips with just one line of terminal commands

A

find *.zip -exec unzip {} \;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Find only files

A

find . -type f

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Find only files … and delete them!

A

find . -type f -delete

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Recursively find files which contain a given text

A

grep -lir “a given text” *

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Find in files but do not search in .git directories

A

grep -Ir –exclude-dir=”.git” “pattern” *

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Move files from nested folders to current directory (“un-nest” them)

A

find . -type f -exec mv {} . \;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Available space in disk

A

df -h

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Show differences between two files without taking into account whitespace (very useful when line returns and spaces/tabs are messing up normal diffs)

A

diff -w file1 file2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Get the md5 hash of a file

A

md5sum filename

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Meaning of:

find . -mtime -1 -print

A

Find files which have been modified today

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Meaning of:

find . -name *~ -print

A

Find all backup files in a directory

17
Q

Meaning of:

find . -name “*~” -exec rm {} \;

A

Find all backup files and delete them!

18
Q

Meaning of:

find . -type d -exec chmod g+x {} \;

A

Change permissions for all folders only

19
Q

Meaning of:

chmod g+s directory

A

Set the group id bit (so files created later in the folder belong to the folder’s group)

20
Q

Meaning of:

find *.zip -exec unzip {} \;

A

Uncompress lots of zips with just one line of terminal commands

21
Q

Meaning of:

find . -type f

A

Find only files

22
Q

Meaning of:

find . -type f -delete

A

Find only files … and delete them!

23
Q

Meaning of:

grep -lir “a given text” *

A

Recursively find files which contain a given text

24
Q

Meaning of:

grep -Ir –exclude-dir=”.git” “pattern” *

A

Find in files but do not search in .git directories

25
# Meaning of: find . -type f -exec mv {} . \;
Move files from nested folders to current directory (“un-nest” them)
26
# Meaning of: df -h
Available space in disk
27
# Meaning of: diff -w file1 file2
Show differences between two files without taking into account whitespace (very useful when line returns and spaces/tabs are messing up normal diffs)
28
# Meaning of: md5sum filename
Get the md5 hash of a file