john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

For loop from file infinite while subdirs cut delimit strtok name diff du sh

while true; do ping -c1 8.8.8.8; sleep 5; done


LASTTOKEN='' while read t; do echo $t LASTTOKEN=$t done < apitokens.txt


!/bin/bash

2012-07-14 johnpfeiffer

function alphabetical() { if [ $# -ne 1 ]; then echo "function alphabetical requires a parameter" exit 0 fi

# includes hidden directories by using . SOURCEDIRS="$1/." for dir in $SOURCEDIRS; do if [ -d $dir ]; then du -sh $dir fi done

SOURCEDIRS="$1/*" for dir in $SOURCEDIRS; do if [ -d $dir ]; then du -sh $dir fi done } # end alphabetical

main

if [ $# -ne 1 ]; then echo "$0 requires a directory to start from, usage: $0 /path" exit 0 fi

echo "$0 listing $1 subdirectories and their sizes with du -sh" alphabetical $1


!/bin/bash

iterate the subdirectories/WEB-INF/app.properties and

compare a text file within to a similarly organized TEMP directory

SOURCE=./* # all of the items in the current directory TARGET=/home/ubuntu/ARCHIVE

for DIRECTORY in $SOURCE; do if [ -d "$DIRECTORY" ]; then DIRECTORYNAME=${DIRECTORY##*/} # extract after the last / echo $DIRECTORYNAME ls $DIRECTORY/WEB-INF/ diff $DIRECTORY/WEB-INF/app.properties $TARGET/$DIRECTORYNAME/WEB-INF/app.properties -w #ignore whitespace/line endings fi done


  • « deferred callback errback callbacks addboth
  • Continuous integration bamboo aws ec2 »

Published

Mar 31, 2014

Category

linux

~160 words

Tags

  • cut 2
  • delimit 1
  • diff 4
  • du 2
  • file 92
  • for 18
  • from 24
  • infinite 1
  • loop 9
  • name 5
  • scripts 63
  • sh 2
  • strtok 1
  • subdirs 3
  • while 1