answersLogoWhite

0


Best Answer

echo -n "Name: "
read n
if [ -f $n ]; then
echo $n is a file
elseif [ -d $n ]; then
echo $n is a directory
fi

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a shell script to accept file name from the user and confirm whether it is a file a directory?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a shell script file called letter1 After running the script it will prompt the user for an English alphabet confirm the alphabet chosen and then search the current directory for all files?

Question is too vague; what do you mean by 'confirm the alphabet chosen'?


Write a shell program using the if-the-else to test whether a variable name is a directory or a file?

# shell script example if [ -f $1 ]; then echo $1 is a file elsif [ -d $1 ]; then echo $1 is a directory fi


What base directory would you put a script in if you wanted it to automatically start when the operating system starts?

What base directory would you put a script in if you wanted it to automatically start when the operating system starts?


What is the alternative to phpmydirectory script?

Phplistings business directory software is the best alternative.


What is the command to verify your source directory exists?

There are several ways to verify a directory. You could use the following test in a shell script: if [ -d some-directory ]; then # directory exists else # directory does not exist fi of use commands such as 'ls 'to see if it exists.


How do you use a script in roblox?

To put a script into something, you have to go to roblox studio and open the dicovery directory thing, click the double click the thing u want it in and make or type a script there. U can also use script builders to see if the scripts work


Can producers accept a script from a non WGA member during the writer's strike?

No


How much for a script?

It's unclear whether you want a computer script in the JavaScript language, or a telvision and film script. Please ask a more specific question.


Is it true that the major film studios cannot legally accept an unrequested script?

Your unrequested script can become a legal issue if it is accepted -- by anyone: major studio, actor, producer, etc. -- because when it is accepted, you can pursue them for monetary damages in the future. Period.So although it is not against the law to accept an unrequested script, the film industry best practices dictate against accepting any unrequested script.Most of the film industry principals will not accept an unrequested script for that reason.


How do you list all files from directory in PHP4?

Here is a small script that will get the files from the $folder variable using a dir function.


Shell script that copies multiple files to a directory?

That's what cp(1) program is good for: cp this that "something else" /dir/to/


How can one create an article directory?

An article directory is a website containing a number of articles written on different subjects. To create an article directory, one would need to have a registered domain name and hosting service. There are a number of software programs that one can use to help set up their website. An example of one such program is Article Directory Script. WordPress is another popular choice for setting up an article directory.