Link Search Menu Expand Document

FreeNAS commands cheat sheet

This are useful commands I have found managing FreeNAS.

Table of contents
  1. Find
  2. Replacement
  3. 2000AD Prog replacement
  4. Move file into folder
  5. Is it a real hyphen?
  6. Move a folder
  7. Authors

Find

| Command | Explanation | | ————- | ————- | | find /mnt/directory1/ -name "Absurd Superpowers*" -type f -exec mv {} /mnt/directory1/moved \; | Find files located in /mnt/directory1 named "Absurd Superpowers*" and move those files to /mnt/directory1/moved | | find /mnt/directory1/ | grep Pool | xargs -I@ mv @ mnt/directory1/moved/ | Find files located in /mnt/directory1 named "Pool" and move those files to /mnt/directory1/moved | | find . -type f -size -3M -delete | Find and delete files located in current directory that is under 3MB in size |


Replacement

Replace volume name, v, with a 0.

#!/bin/sh
for f in *v*; do mv -v "$f" "$(echo "$f" | tr 'v' '0')"; done

2000AD Prog replacement

Replace 2000AD Prog with 2000 AD.

#!/bin/sh
for f in *AD\ Prog*; do mv -v -- "$f" "${f%%AD Prog*} AD ${f#*AD Prog }"; done

Move file into folder

Create a folder for each file based on the first part of the filename of a .pdf before the hyphen, and move the file in to the respective named folder.

root@LazyLibrarian:/mnt/LazyLibrarian # nano script.sh
#!/usr/local/bin/bash
for f in **.pdf; do d=${f%% –*}; mkdir -p "$d" &&  mv "$f" "$d"; done

root@LazyLibrarian:/mnt/LazyLibrarian # chmod +x script.sh

Execute by placing the script.sh file inside unsorted magazine folder, then do ./script.sh and let it work it’s magic.

Then move these folders into your Magazine folder, and hit Library Scan.


Is it a real hyphen?

Check if the - (above) is really a real hyphen.

root@LazyLibrarian:/mnt/LazyLibrarian # printf '–' | od -tx1 -An
          e2  80  93               

http://www.ltg.ed.ac.uk/~richard/utf-8.cgi?input=–&mode=char


Move a folder


Authors

Mr. Johnson