Jump to content

Linux: Difference between revisions

From Costa's Wiki
No edit summary
Costa (talk | contribs)
No edit summary
Line 41: Line 41:
;[[SSL Certificate signed by your own CA]]
;[[SSL Certificate signed by your own CA]]
;[[SD card partition recovery]]
;[[SD card partition recovery]]
;[[How to recreate a wiped /boot filesystem in Ubuntu]]

Revision as of 13:27, 10 September 2025

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
grep -v "^[[:space:]]*$\|^ *#" filename 
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
ssh automation
ssh -i /usr/local/sbin/id_rsa -oStrictHostKeyChecking=no [email protected] 'upsc qnapups'
-i RSA key, -o add to known host automatically
ls with full path
ls -dl $PWD/*
Set date of directories by latest file inside
IFS=$(echo -en "\n\b"); for d in */ ; do T=`ls -alt --time-style="+%Y%m%d0101.10" $d | tail -1 | awk '{print $6}'`; touch -t $T $d; done
Частотный анализ букв в именах файлов
ls | awk '{for (i=1 ; i<=NF ; i++) array[$i]++ } END{ for (char in array) print char,array[char]}' FS="" | sort -k2 -n
Find and replace characters in file name
for file in `IFS=$(echo -en "\n\b"); find . -name "*[+]*" `; do mv -v $file $(echo $file | sed -e 's/+//g'); done


Audiofile operations
Photo file operations
LVM operations
SSL Certificate with SAN
SSL Certificate signed by your own CA
SD card partition recovery
How to recreate a wiped /boot filesystem in Ubuntu