Unix Shell Scripting

5 pts.
Tags:
Linux Scripts
Shell scripts
Ubuntu
Hi,    Its about writing 2 command line argument.First argument i have created a file and put some text to it before writing the script. But i got stuck with second argument its an integer.The script should echo to the standard out put - the message"FILE IS SHORTER". If the number lines in the file named in the first argument is less than the integer the value of second argument should show echo to the standard"FILE IS NOT SHORTER".       can anyone help me with this..

Software/Hardware used:
UBUNTO

Answer Wiki

Thanks. We'll let you know when a new response is added.

Roshan737,

This should be a good start:

#!/bin/bash

if [ $# -eq 2 ]
then
LINES=$1
INTEGER=$2
else
echo “Usage: $0 file integer”
exit
fi

if [ $(wc -l $LINES) -lt "$INTEGER" ]
then
echo “FILE IS SHORTER”
else
echo “FILE IS NOT SHORTER”
fi

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    Can you post your current script ?
    69,510 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following