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

I've already answered you.

Jump to Post

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 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.