Thursday, January 30, 2020

Find and delete files 1 week old (or older)

find /data/files -type f -name "*.txt" -mtime +7 -exec rm {} \;

/data/files - directory
-type f  - find files, not directories, etc
-name "*.txt" - specify file type if necessary
-mtime +7 - modified 7 days or more.  Last accessed time is -atime
-exec rm {}\; - execute rm with the results returned from 'find'

OR

find /data/files -type f -name "*.txt" -mtime +7 | xargs rm

Friday, January 17, 2020

Linux rename file to all lower case


Basic for a directory that only contains files

for file in $(ls); do mv -i ${file} ${file,,}; done

Ignoring directories that contain directories

for file in $(ls -F |grep -v /); do mv -i ${file} ${file,,}; done

Monday, January 6, 2020

Visual Studio Code on Fedora



Import gpg key

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc


Create the Repository

sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'

Install the software

sudo dnf install code