forked from ulrich/useful-linux-command
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
executable file
·44 lines (36 loc) · 1.96 KB
/
README
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
------------------------------------------------
You can add any commands or improve existing one
However, you must follow the current pattern is:
# THE_LINUX_COMMAND_EXPLANATION
THE_LINUX_COMMAND_1
THE_LINUX_COMMAND_2
...
------------------------------------------------
# find string in file
find . -name MY_FILE_PATTERN | xargs grep 'MY_STRING'
# same as above, but just with the file name
find . -name "MY_FILE_PATTERN" -exec grep -l MY_STRING {} \;
# find string in file and give, with, before each file name, the number of time the MY_STRING appears in the file
find . -name "MY_FILE_PATTERN" | xargs grep 'MY_STRING' | awk -F: '{print $1}' | uniq -c
# less on a source file with syntax highlighting (need highlight : http://www.andre-simon.de/doku/highlight/en/highlight.html)
highlight -l -A SOURCE_FILE | less -R
# find string in specified path and file pattern
find . -ipath './MY_DIRECTORY/FOOBAR/*/*.MY_EXTENSION' | xargs grep 'MY_STRING'
# open files in editor which string match in files
gedit `find . -ipath './MY_DIRECTORY/FOOBAR/*/*.MY_EXTENSION' | xargs grep 'MY_STRING' | awk -F: '{print $1}'`
# open files in editor which string match in files
find . -ipath './MY_DIRECTORY/FOOBAR/*/*.MY_EXTENSION' -exec perl -pi -e 's/MY_ORIG_STRING/MY_REPLACED_STRING/' {} \;
# replace string in files which strings match in files
find . -ipath './merlin-data/src/*/*.xml' -exec perl -pi -e 's/http:\/\/hibernate.sourceforge.net\//http:\/\/www.hibernate.org\/dtd\//' {} \;
# delete files recursively
$ find . -name .DS_Store -delete
# erase a CDRW
sudo cdrecord blank=all -immed dev=/dev/cdrw
# extract audio from a video (without reencoding it)
ffmpeg -i mandelbrot.flv -vn -acodec copy mandelbrot.mp3
# display a desktop notification
notify-send "Title" "This is a message"
# When the system's freezed :
Keep Left Alt & Print Screen pressed, then R, S, E, I, U, B
# Find broken symlinks in a specified directory
for i in `find MY_DIRECTORY -type l`; do [ -e $i ] || echo $i is broken; done