i want to give a filename in commandline itself and want to check whether it is a directory are not.shall i use this command

if [ -f $filename ]

Recommended Answers

All 2 Replies

I've already answered you.

if [ -d $1 ]; then
  ls -l $1>file1.txt;
  awk -f '{print tolower($8)}' file1.txt;
else 
  echo "it is not a directory";
fi
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.