Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

BASH SCRIPT IN LINUX Write a script named long_file.sh to find the longest file name in a directory. long_file.sh will accept a directory name as

BASH SCRIPT IN LINUX Write a script named long_file.sh to find the longest file name in a directory. long_file.sh will accept a directory name as the first argument and determine the longest filename in that directory. If the correct number of arguments are not provided, print an error message to standard output and exit the script with a return error of 1. If the scripts's first argument is not a directory name, print an error message to standard output and exit with a return code of 1. If a the first argument is a directory, print the directory name prior to printing the longest filename and length. 
If there are multiple files with the same length, you need to print all the files if there are multiple files names with the same greatest length. A Bash array is good choice for storing multiple filenames. Example run: $ ./long_file.sh /home/michelle/temp Directory: /home/michelle/temp Longest filename: longerfilenameishere Longest filename len: 20 Directory listing from test directory $ ls /home/michelle/temp file1 file2 file3 file4 longerfilenameishere Example run 2: $ ./long_file.sh Usage: ./long_file.sh directory Example run 3: $ ./long_file.sh file1 First parameter must be a directory (file)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Current Trends In Database Technology Edbt 2006 Edbt 2006 Workshops Phd Datax Iidb Iiha Icsnw Qlqp Pim Parma And Reactivity On The Web Munich Germany March 2006 Revised Selected Papers Lncs 4254

Authors: Torsten Grust ,Hagen Hopfner ,Arantza Illarramendi ,Stefan Jablonski ,Marco Mesiti ,Sascha Muller ,Paula-Lavinia Patranjan ,Kai-Uwe Sattler ,Myra Spiliopoulou ,Jef Wijsen

2006th Edition

3540467882, 978-3540467885

More Books

Students also viewed these Databases questions