[sh] Write Linux path content on a .txt file with “ls” command

Posted by

On Linux environments normally you work with shared hard drives with bunches of data, by default some systems use the same path. Days ago “securitytweak.com” published a script to move data reading from a file, this post can help you to write the path content to a .txt file.

#!/bin/sh

#
#Autor: brenseg
#Year: 2019
#

PATH_SOURCE=/home/securitytweak/datafiles
PATH_DEST=/home/valparaiso/datafiles_backup
CONTENT=/home/brenseg

echo “—————“
echo ” Getting data…”
echo “—————“
sleep 1
echo “**3**”
sleep 1
echo “**2**”
sleep 1
echo “**1**”
echo “—————“

echo “Start: `date`”
START=`date +%s`

ls $PATH_SOURCE >> $CONTENT/content.txt

SPENT=$(((`date +%s` – $START)/60))

echo “End: `date`”
echo “Duration: $SPENT minutes”
exit 0

Advertisements

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s