#!/bin/sh
# Filename: organize.sh
# Description: A simple program that will transfer
# selected files to a certain directory
# Author: Obispo
# create a directory for c files
mkdir cfiles
# create a directory for sh files
mkdir shfiles
# transfer all c source codes to cfiles directory
for f in `ls *.c`
do
mv ${f} ./cfiles
done
# transfer all shell scripts to shfiles directory
for f in `ls *.sh`
do
mv ${f} ./shfiles
done
exit 0
Okay, here's how I came up with the program. If I'll execute the command 'ls *.c' at the console, it will display all the files that ends with '.c' right? So what I did was to get these files that ends with '.c' one by one and place it in a variable called 'f' then move it to my cfiles directory. The Unix command to move a file to another directory is 'mv'.
No comments:
Post a Comment