tail limit in sunos


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting tail limit in sunos
# 1  
Old 05-28-2012
tail limit in sunos

my systems are linux red hat and sunos.

i have files that i tail.

in linux, it seems i can tail as many lines as i want without the tail command hanging.

in sun however, if i tail a huge number of lines, the command just hangs.

my question is, is there a better way to tail a file? something different from a tail -f.

i need to be able to tail x number of lines in a file. how can i do this efficiently in sun and/or linux
# 2  
Old 05-28-2012
Hi.

What is huge to you (and sun)?

Do you know that tail on the sun is not simply positioning the file?

There is a perl version of tail at PPT: Which commands? -- I have not used it, but I have used other command work-alikes from that project.

Best wishes ... cheers, drl
# 3  
Old 05-28-2012
Quote:
Originally Posted by drl
Hi.

What is huge to you (and sun)?

Do you know that tail on the sun is not simply positioning the file?

There is a perl version of tail at PPT: Which commands? -- I have not used it, but I have used other command work-alikes from that project.

Best wishes ... cheers, drl
huge is anything sun stalls on. i originally wanted to tail the last 500,000 lines and redirect to a file.

id rather not use perl in in this case, unless there's a one-liner type of perl command that can do this.
# 4  
Old 05-28-2012
Hi.

Both standard and xpg4 tail versions seem to work for me:
Code:
#!/usr/bin/env bash

# @(#) s1       Demonstrate tail for long segment.

xTAIL=/usr/xpg4/bin/tail
sTAIL=/usr/bin/tail
pTAIL=$HOME/bin/perl-tail
pe() { for _i;do printf "%s" "$_i";done; printf "\n"; }
pl() { pe;pe "-----" ;pe "$*"; }
db() { ( printf " db, ";for _i;do printf "%s" "$_i";done;printf "\n" ) >&2 ; }
db() { : ; }
cs() { echo "$1" | perl -wp -e '1 while s/^([-+]?\d+)(\d{3})/$1,$2/; ' ; }
C=$HOME/bin/context && [ -f $C ] && $C $sTAIL $xTAIL

pe
FILE=${1-/tmp/100-mb.txt}
lines=$( cs $( wc -l < $FILE) )
chars=$( cs $( wc -c < $FILE) )
pl " Input file $FILE has $lines lines, $chars characters."

# Use standard tail.
TAIL=$sTAIL
pl " Results for tail version $TAIL:"
for i in 1 10 100 100000 200000 500000
do
  n=$( $TAIL -$i $FILE | wc -l )
  if [[ n -eq i ]]
  then
    pe " $TAIL successful for $i lines."
  else
    pe " $TAIL failed for $i lines."
  fi
done

# Use xpg4 tail.
TAIL=$xTAIL
pl " Results for tail version $TAIL:"
for i in 1 10 100 100000 200000 500000
do
  n=$( $TAIL -$i $FILE | wc -l )
  if [[ n -eq i ]]
  then
    pe " $TAIL successful for $i lines."
  else
    pe " $TAIL failed for $i lines."
  fi
done

exit 0

producing:
Code:
% ./s1

Environment: LC_ALL = C, LANG = C
(Versions displayed with local utility "version")
OS, ker|rel, machine: SunOS, 5.10, i86pc
Distribution        : Solaris 10 10/08 s10x_u6wos_07b X86
GNU bash 3.00.16
/usr/bin/tail - ( /usr/bin/tail, Jun 8 2006 )
/usr/xpg4/bin/tail - ( local: /usr/xpg4/bin/tail, Jun 8 2006 )


-----
 Input file /tmp/100-mb.txt has 1,777,700 lines, 120,540,400 characters.

-----
 Results for tail version /usr/bin/tail:
 /usr/bin/tail successful for 1 lines.
 /usr/bin/tail successful for 10 lines.
 /usr/bin/tail successful for 100 lines.
 /usr/bin/tail successful for 100000 lines.
 /usr/bin/tail successful for 200000 lines.
 /usr/bin/tail successful for 500000 lines.

-----
 Results for tail version /usr/xpg4/bin/tail:
 /usr/xpg4/bin/tail successful for 1 lines.
 /usr/xpg4/bin/tail successful for 10 lines.
 /usr/xpg4/bin/tail successful for 100 lines.
 /usr/xpg4/bin/tail successful for 100000 lines.
 /usr/xpg4/bin/tail successful for 200000 lines.
 /usr/xpg4/bin/tail successful for 500000 lines.

Best wishes ... cheers, drl
# 5  
Old 05-28-2012
It is important that you provide accurate information because there are limitations on basic unix commands which vary from SunOS version to version.

Please state the exact version of SunOS.

How large is the largest file, and how many records does that file contain?
# 6  
Old 05-28-2012
Quote:
Originally Posted by methyl
It is important that you provide accurate information because there are limitations on basic unix commands which vary from SunOS version to version.

Please state the exact version of SunOS.

How large is the largest file, and how many records does that file contain?
sun 5.10

basically, if i wanted to tail the last 500,000 lines of a file and redirect it to a file, what is the best way to do it?

that should have been my original question.

i need a command that works across both linux and sunos servers. i'm almost certain sed should have a hack for this.
# 7  
Old 05-28-2012
Hi.

For GNU/Linux:
Code:
#!/usr/bin/env bash

# @(#) s1	Demonstrate tail for long segment.

xTAIL=/usr/xpg4/bin/tail
sTAIL=/usr/bin/tail
pTAIL=$HOME/bin/perl-tail
pe() { for _i;do printf "%s" "$_i";done; printf "\n"; }
pl() { pe;pe "-----" ;pe "$*"; }
db() { ( printf " db, ";for _i;do printf "%s" "$_i";done;printf "\n" ) >&2 ; }
db() { : ; }
cs() { echo "$1" | perl -wp -e '1 while s/^([-+]?\d+)(\d{3})/$1,$2/; ' ; }
C=$HOME/bin/context && [ -f $C ] && $C $sTAIL $xTAIL

pe
FILE=${1-/tmp/100-mb.txt}
lines=$( cs $( wc -l < $FILE) )
chars=$( cs $( wc -c < $FILE) )
pl " Input file $FILE has $lines lines, $chars characters."

# Use standard tail.
TAIL=$sTAIL
pl " Results for tail version $TAIL:"
for i in 1 10 100 100000 200000 500000
do
  n=$( $TAIL -$i $FILE | wc -l )
  if [[ n -eq i ]]
  then
    pe " $TAIL successful for $i lines."
  else
    pe " $TAIL failed for $i lines."
  fi
done
exit

# Use xpg4 tail.
TAIL=$xTAIL
pl " Results for tail version $TAIL:"
for i in 1 10 100 100000 200000 500000
do
  n=$( $TAIL -$i $FILE | wc -l )
  if [[ n -eq i ]]
  then
    pe " $TAIL successful for $i lines."
  else
    pe " $TAIL failed for $i lines."
  fi
done

exit 0

producing:
Code:
% ./s1

Environment: LC_ALL = C, LANG = C
(Versions displayed with local utility "version")
OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64
Distribution        : Debian GNU/Linux 5.0.8 (lenny) 
bash GNU bash 3.2.39
/usr/bin/tail tail (GNU coreutils) 6.10
 command "/usr/xpg4/bin/tail" not found.


-----
 Input file /tmp/100-mb.txt has 1,777,700 lines, 120,540,400 characters.

-----
 Results for tail version /usr/bin/tail:
 /usr/bin/tail successful for 1 lines.
 /usr/bin/tail successful for 10 lines.
 /usr/bin/tail successful for 100 lines.
 /usr/bin/tail successful for 100000 lines.
 /usr/bin/tail successful for 200000 lines.
 /usr/bin/tail successful for 500000 lines.

Best wishes ... cheers, drl
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Tail +

because the tail +2 on the first line gives me the file name pomga I do not want anything like what I miss tail +2 ejemplo.txt ouput ==> ejemplo.txt <== 1 2 3 4 5 6 7 8 9 10 (2 Replies)
Discussion started by: tricampeon81
2 Replies

2. Shell Programming and Scripting

Joining multiple files tail on tail

I have 250 files that have 16 columns each - all numbered as follows stat.1000, stat.1001, stat.1002, stat.1003....stat.1250. I would like to join all 250 of them together tail by tail as follows. For example stat.1000 a b c d e f stat.1001 g h i j k l So that my output... (2 Replies)
Discussion started by: kayak
2 Replies

3. Solaris

Limit: stacksize: Can't remove limit

Hi all, I'm using to Solaris machine. When I run a simple script this messenger come out:"limit: stacksize: Can't remove limit". Any one know the way to resolve this problem without reboot the machine? Thanks in advance. (3 Replies)
Discussion started by: Diabolist9
3 Replies

4. Solaris

Looking for help with SunOS 5.6

Hey all, I've got my hands on 10 SunOS 5.6 SPARCStation 20 machines and I'm looking to get them up and running. They're all in various states of disrepair but I've got them all to a state where the hardware is working and the machine will at least attempt to boot. I've only used Solaris as a... (1 Reply)
Discussion started by: kevpatts
1 Replies

5. Solaris

SunOS 5.4

Hi, I Hope you can help me with my problem. I need to have an installation CD of this version. Is there any site you can recommend that I can download an image of this OS? Thanks and God Bless!!! (6 Replies)
Discussion started by: mr_balodoy
6 Replies

6. Shell Programming and Scripting

tail -f

I am trying to extract a particular line from a.log which keeps appending every sec and output that into a newfile b.log which should append itself with filtered data received from a.log I tried tail -f a.log |grep fail| tee -a b.log nothing in b.log tail -f a.log |grep fail >>b.log ... (4 Replies)
Discussion started by: wannalearn
4 Replies

7. Shell Programming and Scripting

Tail??

Hello all, I have search the forum and could not find an answer...Here is what I am trying to do. Every 15 minutes, a script send uptime output to a logfile (dailylog.log), that file contains lines like the one below: 11:21am up 44 days, 19:15, 1 user, load average: 0.00, 0.02, 0.03 ... (7 Replies)
Discussion started by: qfwfq
7 Replies

8. UNIX for Advanced & Expert Users

Migration of binary file from Sunos 5.8 to Sunos 5.9

I have compiled binary file using "cc" on SunOS 5.8 and the same binary file i have copied to SunOS 5.9 and it is giving me core dump error.I want to know whether migration of compiled code from lower version to higer version created this problem. how can i solve this problem.I am pasting the core... (1 Reply)
Discussion started by: Arvind Maurya
1 Replies

9. Shell Programming and Scripting

SunOS 5.8

I am loging into a SunOS 5.8 box for the first time. I do not see a .profile file in the home directory. Also on the command line when I type a backspace to correct my typing I get a ^H character. Where and how can I fix this? Thanks in advance (5 Replies)
Discussion started by: jxh461
5 Replies

10. Shell Programming and Scripting

using tail -f

Working in HP-UX 10.20. I eventually want to write a bourne shell script to handle the following problem, but for now I am just toying with it at the command line. Here's what I am basically trying to do: tail -f log_X | grep n > log_Y I am doing a tail -f on log_X . Once it sees "n", I... (6 Replies)
Discussion started by: cdunavent
6 Replies
Login or Register to Ask a Question