Browsing the archives for the bash tag.

Bash Find On A Large Dataset – Write The Results To A File

Examples

A fast bash based solution for executing a find on a directory with a lot of files that you want to log to a file:

find /my/data/  -name '*.xml' -type f -fprint my_xml_files.txt

This example looks in the /my/data/ directory for all files with the xml extension and then writes the results to the my_xml_files.txt file.

No Comments

Format The Date Command In Bash

Examples

Formatting the date output in bash is simple:

date + "%Y-%m-%d";

An example of assigning to a variable and using:

now=`date + "%Y-%m-%d"`;
cp /etc/hosts ~/hosts_${now};

For more information, see the manual.

No Comments