Linux: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
| Line 14: | Line 14: | ||
;How to print a file, excluding comments and blank lines, using grep | ;How to print a file, excluding comments and blank lines, using grep | ||
<pre>grep -v '^$\|^#\|^\s*\#' filename | grep -v "^[[:space:]]*$" | more</pre> | <pre>grep -v '^$\|^#\|^\s*\#' filename | grep -v "^[[:space:]]*$" | more</pre> | ||
;bash operations with file with spaces in name | |||
IFS=$(echo -en "\n\b"); for i in $(ls -d */ | cut -f1 -d'/'); do echo $i; done | |||
IFS=$(echo -en "\n\b"); for i in $(ls -d */ | cut -f1 -d'/'); do echo "$i;"| tr -d '\r\n'; find $i -type f | wc -l; done | |||
;[[Audiofile operations]] | ;[[Audiofile operations]] | ||
;[[LVM operations]] | ;[[LVM operations]] | ||
;[[SSL Certificate with SAN]] | ;[[SSL Certificate with SAN]] | ||
Revision as of 09:38, 27 May 2022
- Copy directories without content
rsync -av -f"+ */" -f"- *" "$source" "$target"
- Find files
find /path/to/dir -type f -name "*" -newermt 2013-02-07 ! -newermt 2013-02-08 find $HOME/projects -type f -name "*.py" -newermt 2013-02-07 ! -newermt 2013-02-08 -print find $HOME/projects -type f -name "*.py" -newermt 2013-02-07 ! -newermt 2013-02-08 -ls
- Delete Files older Than
find /var/log -name "*.log" -type f -mtime +30 -delete
find /var/log -type d -mtime +30 -exec rm -rf {} \;
- How to print a file, excluding comments and blank lines, using grep
grep -v '^$\|^#\|^\s*\#' filename | grep -v "^[[:space:]]*$" | more
- bash operations with file with spaces in name
IFS=$(echo -en "\n\b"); for i in $(ls -d */ | cut -f1 -d'/'); do echo $i; done IFS=$(echo -en "\n\b"); for i in $(ls -d */ | cut -f1 -d'/'); do echo "$i;"| tr -d '\r\n'; find $i -type f | wc -l; done