20050819
20050817
20050810
Unix: Old dog, new tricks
Renaming files in linux:
To rename all files ending in ".old" to ".new", use the following:
for i in *.old; do echo mv $i `basename $i .old`.new; done
To remove the first few characters from a file, you can try the following:
for i in *; do echo mv $i `echo $i | tr -d "wqy"`; done
To rename/change uppercase to lowercase in current directory:
for i in `ls`; do mv $i `echo $i | tr '[A-Z]' '[a-z]'`; done
To rename/change uppercase to lowercase excluding directories:
for i in `find . -type f -print`; do
base=`basename $i`;
echo mv $i `dirname $i`/`echo $base | tr '[a-z]' '[A-Z]'`;
done
To rename/change uppercase to lowercase directories:
for i in `find . -print -maxdepth 1 -type d | grep [a-z]`; do
echo mv $i `echo $i | tr '[a-z]' '[A-Z]'`;
done
Remove markup tags in files:
cat filename.xml |sed -e "s/<\/*tagname>//gi"
cat filename.xml |sed -e "s/<\/*tagName>//g"
To rename all files ending in ".old" to ".new", use the following:
for i in *.old; do echo mv $i `basename $i .old`.new; done
To remove the first few characters from a file, you can try the following:
for i in *; do echo mv $i `echo $i | tr -d "wqy"`; done
To rename/change uppercase to lowercase in current directory:
for i in `ls`; do mv $i `echo $i | tr '[A-Z]' '[a-z]'`; done
To rename/change uppercase to lowercase excluding directories:
for i in `find . -type f -print`; do
base=`basename $i`;
echo mv $i `dirname $i`/`echo $base | tr '[a-z]' '[A-Z]'`;
done
To rename/change uppercase to lowercase directories:
for i in `find . -print -maxdepth 1 -type d | grep [a-z]`; do
echo mv $i `echo $i | tr '[a-z]' '[A-Z]'`;
done
Remove markup tags in files:
cat filename.xml |sed -e "s/<\/*tagname>//gi"
cat filename.xml |sed -e "s/<\/*tagName>//g"
20050805
Subscribe to:
Posts (Atom)