- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: shell script help
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-07-2004 02:53 AM
тАО12-07-2004 02:53 AM
do
case $LINE in
.............
...........
......
Quesiton:: is there anyway of finding out the line i m reading in $LINE variable is the last line in the file ?
Any help?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-07-2004 02:56 AM
тАО12-07-2004 02:56 AM
SolutionlineCount=$(wc -l $scriptpath/synclogs.log)
lineNumber=0
cat $scriptpath/synclogs.log | while read LINE
do
lineNumber=$(($lineNumber+1))
if [ $lineNumber -eq $lineCount] ; then
echo Last one
fi
case $LINE in
.............
...........
......
done
Regards,
Fred
"Reality is just a point of view." (P. K. D.)
- Tags:
- wc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-07-2004 02:57 AM
тАО12-07-2004 02:57 AM
Re: shell script help
nrec=`wc -l synclogs.log`
Then count up each record.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-07-2004 03:00 AM
тАО12-07-2004 03:00 AM
Re: shell script help
I would do something like a
LIN=`cat file | wc -l `
NUM=0
cat file | while read LINE
do
let NUM="$NUM ++1"
case $LINE in
...
if [ $NUM -eq $LIN ]
then
exit 0
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-07-2004 03:02 AM
тАО12-07-2004 03:02 AM
Re: shell script help
Before the cat statement do:
LASTLINE=$(tail -1 $scriptpath/synclogs.log)
Then in your 'while do' loop:
if [[ "${LINE}" = "${LASTLINE}" ]] ; then
...do what you wanna do...
else
...do something else...
fi
The above works on the assumption that each line is somehow unique, which could be a problem if it's a log file.
- Tags:
- tail
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-07-2004 03:10 AM
тАО12-07-2004 03:10 AM
Re: shell script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-07-2004 03:13 AM
тАО12-07-2004 03:13 AM
Re: shell script help
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-07-2004 03:18 AM
тАО12-07-2004 03:18 AM
Re: shell script help
can u suggest any other way of reading line other than "pipe" and then used EOF marker to check last line ?
any suggestion ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-07-2004 03:22 AM
тАО12-07-2004 03:22 AM
Re: shell script help
I'm curious. What problem are you trying to solve? Using the while-read-do-done structure will read each line of the file, and the statements in your script immediately after the done line will be executed after the last line of the file is read, so you should be able to handle whatever you need to do after the end of file at that point.
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-20-2005 11:18 PM
тАО02-20-2005 11:18 PM