06-18-2001
It's good to pick up these sorts of shortcuts to save a lot of time when in a hurry or under pressure - the little things like knowing a flag here and there often make the difference between finding a vital piece of information that can lead to solving a problem.
As with most general issues there are many ways to do things in UNIX - you could have piped tail into the more command to achieve the same effect, variety is the spice of of life!
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi, just a quick question really on what the <<! at the end of a line actually means ? as you can see i have an oracle startup script that has an sqlplus command. im making a guess here, so correct me if im wrong but the "startup" and "exit" commands that follow are sqlplus command and not unix... (3 Replies)
Discussion started by: hcclnoodles
3 Replies
2. UNIX for Dummies Questions & Answers
how can I add data from command line to end of file? (3 Replies)
Discussion started by: bryan
3 Replies
3. Shell Programming and Scripting
hi,
could anyone tell me the command to append spaces at the end of the line.
for example, i need 1000 spaces after the word "helloworld"
echo "helloworld " i need to achieve this in someother way hardcoding 1000 spaces is not practical.
as i am totally new... (3 Replies)
Discussion started by: kavithacs
3 Replies
4. Programming
hello,
i use this command in my code:
(void) sprintf ( LBuf, "/bin/sed 's/\\//g' %s > %s", tmp1,tmp2);
but i get this error :
sh: syntax error at line 1:'end of file' unexpected
any help please
thank you (1 Reply)
Discussion started by: kamel.seg
1 Replies
5. Shell Programming and Scripting
Hi,
I want to add \n as a EOF at the end of file if it does't exist in a single command. How to do this?
when I use command
echo "1\n" > a.txt
and
od -c a.txt
0000000 1 \n \n
0000003
How does it differentiate \n and eof in this case?
Regards,
Venkat (1 Reply)
Discussion started by: svenkatareddy
1 Replies
6. Shell Programming and Scripting
I am looking to change a data file into a javascript string and this is the code that I am using:
sed -i '' -e 's/^/str += "/' -e 's/$/";/' file.xml
The first part
-e 's/^/str += "/'
works as intended, but the second part
-e 's/$/";/'
adds an additional newline to my file, so that instead of... (3 Replies)
Discussion started by: figaro
3 Replies
7. UNIX for Dummies Questions & Answers
I have text file which is a tab delimited one. Sample data from the file is shown below:
unix is\ great\ os
linux\ is superb
I want to replace that backslash with empty string preserving the tab delimiter. Output should be
unix is great os
linux is ... (3 Replies)
Discussion started by: p.akhilreddy4u
3 Replies
8. Shell Programming and Scripting
Hi ,
Am trying to send mail using the mail command, but the mail command is working but its not sending automatically after pressing .(dot) in the command prompt it sends . How to achieve that. Also it showing the below line after pressing the dot .
/home/abc1/dead.letter... Saved message in... (5 Replies)
Discussion started by: rogerben
5 Replies
9. Shell Programming and Scripting
Oracle Enterprise Linux
We want to track how long a process takes to complete its execution. This is what we want in the schell script
Before the process is started , get the time with date, hours and minutes
execute the process
After the process has ended , get the time with date,... (5 Replies)
Discussion started by: omega3
5 Replies
10. Shell Programming and Scripting
hello Team,
I am looking for sed command or script which will append word at end of line. for example. I want to validate particular filesystem with mount |<filesystem name> command. if nodev parameter is not there then it should add in the fstab file with receptive to the filesystem.
# mount... (8 Replies)
Discussion started by: ghpradeep
8 Replies
LEARN ABOUT SUSE
pdl::tips
TIPS(1) User Contributed Perl Documentation TIPS(1)
NAME
PDL::Tips - Small tidbits of useful arcana. Programming tidbits and such.
SYNOPSIS
use PDL;
# Whatever happens here.
DESCRIPTION
This page documents useful idioms, helpful hints and tips for using Perl Data Language v2.0.
Help
Use "help help" within perldl or the "pdldoc" program from the command line for access to the PerlDL documentation. HTML versions of the
pages should also be present, in the HtmlDocs/PDL directory of the PDL distribution. To find this directory, try the following
perldl> foreach ( map{"$_/PDL/HtmlDocs"}@INC ) { p "$_
" if -d $_ }
Indexing idioms
The following code normalizes a bunch of vectors in $a. This works regardless of the dimensionality of $a.
$a /= $a->sumover->dummy(0);
What is actually happening?
If you want to see what the code is actually doing, try the command
PDL::Core::set_debugging(1);
somewhere. This spews out a huge amount of debug info for PDL into STDOUT. It is planned to eventually make this redirectable and the
messages selectable more accurately.
Many of the messages come from "Basic/Core/pdlapi.c" and you can look at the source to see what is going on.
If you have any extra time to work on these mechanisms, infrom the pdl-porters mailing list.
Memory savings
If you are running recursively something that selects certain indices of a large piddle, like
while(1) {
$inds = where($a>0);
$a = $a->index($inds);
$b = $b->index($inds);
func($b,$a);
}
If you are not writing to $b, it saves a lot of memory to change this to
$b = $b->index($inds)->sever;
The new method "sever" is a causes the write-back relation to be forgotten. It is like copy except it changes the original piddle and
returns it).
Of course, the probably best way to do the above is
$inds = xvals ($a->long);
while(1) {
$inds0 = where($a>0);
$inds1 = $inds->index($inds)->sever;
$a = $a0->index($inds1);
$b = $b->index($inds1)->sever;
func($b,$a);
}
which doesn't save all the temporary instances of $a in memory. See "mandel.pl" in the Demos subdirectory of the PerlDL distribution for
an example.
PP speed
If you really want to write speedy PP code, the first thing you need to do is to make sure that your C compiler is allowed to do the
necessary optimizations.
What this means is that you have to allow as many variables as possible to go into registers:
loop(a) %{
$a() += $COMP(foo_member) * $b()
%}
expands to
for(i=0; i<10000; i++) {
a[i] += __privtrans->foo_member * b[i];
}
is about the worst you can do, since your C compiler is not allowed to assume that "a" doesn't clobber "foo_member" which completely
inhibits vectorization. Instead, do
float foo = $COMP(foo_member);
loop(a) %{
$a() += foo * $b();
%}
This is not a restriction caused by PP but by ANSI C semantics. Of course, we could copy the struct into local varibles and back but that
could cause very strange things sometimes.
There are many other issues on organizing loops.
We are currently planning to make PP able to do fixed-width things as well as physical piddles (where looping over the first dimensions
would be cheaper as there are less distinct increments, which might make a difference on machines with a small number of registers).
AUTHOR
Copyright (C) Tuomas J. Lukka 1997. All rights reserved. Duplication in the same form and printing a copy for yourself allowed.
perl v5.12.1 2009-10-17 TIPS(1)