msgbartop
A chronological documentation test project, nothing serious, really!
msgbarbottom

04 Jul 2013 Create random filenames with random content

I wanted to test filesystem checking on a large XFS filesystem and needed to fill the filesystem. The task was to create files on random with different file size and names placed in different folders.

The script I found on the Internet does exactly that

#!/bin/bash
# Created by Ben Okopnik on Wed Jul 16 18:04:33 EDT 2008
######## User settings ############
MAXDIRS=15
MAXDEPTH=7
MAXFILES=100000
MAXSIZE=8000000000
######## End of user settings ############
# How deep in the file system are we now?
TOP=`pwd|tr -cd '/'|wc -c`
populate() {
cd $1
curdir=$PWD
files=$(($RANDOM*$MAXFILES/32767))
for n in `seq $files`
do
f=`mktemp XXXXXX`
size=$(($RANDOM*$MAXSIZE/32767))
head -c $size /dev/urandom > $f
done
depth=`pwd|tr -cd '/'|wc -c`
if [ $(($depth-$TOP)) -ge $MAXDEPTH ]
then
return
fi
unset dirlist
dirs=$(($RANDOM*$MAXDIRS/32767))
for n in `seq $dirs`
do
d=`mktemp -d XXXXXX`
dirlist="$dirlist${dirlist:+ }$PWD/$d"
done
for dir in $dirlist
do
populate "$dir"
done
}
populate $PWD

Source: http://linuxgazette.net/153/pfeiffer.html

Tags: , , , ,

Posted by

14 Mar 2007 Delete all newlines from a file

tr -d '\n' < file

Tags:

Posted by

14 Mar 2007 Translate uppercase characters to their corresponding lowercases

cat file| tr 'A-Z' 'a-z'

Tags:

Posted by

17 Feb 2007 Convert everything in the current directory from upper- to lowercase.

A bash script to convert everything from upper- to lowercase.
"!/bin/bash
for n in *; do mv $n `echo $n | tr '[:upper:]' '[:lower:]'`; done

Tags: ,

Posted by

09 Feb 2007 Convert DOS Carriage Return file to Unix Line feed file

tr '\r' '\n' < sourcefile_dos.txt > resultfile_unix.txt

An alternative is to use the program hd2u which is a DOS < –> Unix convertor

dos2unix -U 2006-12.md5

Converts from DOS to Unix, doing a Unix to DOS use the -D switch.

Tags: ,

Posted by