Logo 
Search:

Unix / Linux / Ubuntu Articles

Submit Article
Home » Articles » Unix / Linux / Ubuntu » Homework HelpRSS Feeds

Write a shell scripts which works similar to the Unix commands Head Tail

Posted By: Alexandra Hughes     Category: Unix / Linux / Ubuntu     Views: 5658

Write a shell scripts which works similar to the Unix commands Head Tail

Code for Write a shell scripts which works similar to the Unix commands Head Tail in Unix / Linux / Ubuntu

for dir in `ls`
doif [ -f $dir ] 
    then
        line=`wc -l $dir | cut -d" " -f1`
echo $line
        if [ $line -gt 10 ]
        then
            head -2 $dir
            tail -3 $dir
        else
            echo "Less 10 line"
            cat $dir
        fi    
    fi    
done
  
Share: 



Alexandra Hughes
Alexandra Hughes author of Write a shell scripts which works similar to the Unix commands Head Tail is from London, United Kingdom.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!