First post on StackOverflow, first time using Bash.
I'm currently trying to construct a function to read a file, then give me out put depending on the status:
- If it's a file, then print the name, size and type
- If it's a symbolic link, then print the name and it's target
- If it's a directory, then recursively call the function on each item.
- Otherwise return 'unknown'
I know the code is rough so far, but all I really need help with is the recursive looping part. How do I loop through the contents of a directory using a While Loop?
Here's my code so far:
#!/bin/bash
function fileChecker f  {
    if [-e $1 ]; then
        if [ -f $1]; then 
            SIZE = 'du -k $1 | cut -f1'
            CONTENT = 'file $1 | cut -d':' -f2'
            echo $1 +" " +  $SIZE + " " + $CONTENT
    elif[ -h $1 ]; then
        LINK = get info from $1
        echo $1 + " " + "symbolic link " + $LINK
    elif [ -d $1 ]; then 
        while  [ ???? ]; do  
            fileChecker n
        do
    else
        echo $1 + "unknown"
    fi
fi 
}
Thanks in advance!
 
    