LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-24-2005, 01:59 PM   #1
herve2001
Member
 
Registered: Sep 2004
Posts: 34

Rep: Reputation: 15
Shell scripting pros


I'm looking for some help from anyone who knows shell scripting, I'm trying to do the following:

1-Accept a string form the terminal and use case to echo a suitable message if the string doesn't have at least 10 characters.

and

2-Write a script that displays, in head-style, the last three lines of each file in the current directory, duly preceded by the filename.


Thanks.
 
Old 02-24-2005, 02:13 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
1)
Code:
#!/bin/bash

if [ `echo -n $1|wc -m` -lt 10 ];then
 echo Less than 10 chars.
fi
2) tail -vn 3 *
 
Old 02-24-2005, 02:13 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
/me sniffs the air ... "Eeeew, this reeks of homework!"

If this is a homework question, please read the RULES
again that you accepted when you signed up.



Cheers,
Tink
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 03:14 AM
shell interface vs shell scripting? I'm confused jcchenz Linux - Software 1 10-26-2005 04:32 PM
Need help from pros in shell scripting? aLiVe Linux - Newbie 18 08-12-2004 10:37 AM
Need help from pros in shell script aLiVe Programming 1 08-08-2004 05:50 AM
Shell Scripting, I think... AMDPwred Linux - General 1 04-06-2002 01:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration