02-14-2009
Ah-ha. Okay, I think I'm onto something... I spent some time researching the line terminator thing (have been since last night actually) but everything I came up with kept telling me that my line terminator was Unix-style. Just now though, I punched file FirstLine.txt into Terminal and it came back with FirstLine.txt: ASCII text, with no line terminators.
Great. So... how do I insert a line terminator? I found many, many resources that talk about the tr command and changing \r to \n but nothing in the way of adding a line terminator where none exists.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello.
Consider the following magic words:
# ls `which adduser`
ls: /usr/sbin/adduser: No such file or directory
#
Hmmm...
Then:
# ls /usr/sbin/adduser
/usr/sbin/adduser
#
Now what?
Unforunately this little sniippet is used in my debian woody server's mysql pre install script.... (2 Replies)
Discussion started by: osee
2 Replies
2. Shell Programming and Scripting
Hi,
I use the command
ls a\b\c\*.txt
from the command line on HP UNIX and it works fine - It lists all files matching *.txt in the a\b\c directory
When embeded in a ksh script
`ls a\b\c\*.txt`
it does not work - I get *.txt not found (even though there are files)
I tried... (10 Replies)
Discussion started by: GNMIKE
10 Replies
3. UNIX for Dummies Questions & Answers
I have a script with a find command using xargs to copy the files found to another directory. The find command is finding the appropriate file, but it's not copying. I've checked permissions, and those are all O.K., so I'm not sure what I'm missing. Any help is greatly appreciated.
This is... (2 Replies)
Discussion started by: mpflug
2 Replies
4. Shell Programming and Scripting
Hello,
So I sorted my file as I was supposed to:
sort -n -r -k 2 -k 1 file1 | uniq > file2
and when I wrote
> cat file2
in the command line, I got what I was expecting, but in the script itself
...
sort -n -r -k 2 -k 1 averages | uniq > temp
cat file2
It wrote a whole... (21 Replies)
Discussion started by: shira
21 Replies
5. Shell Programming and Scripting
total=0
seq 1 5 | while read i ; do
total=$(($total+$i))
echo $total
done
echo $totalThis outputs:
1
3
6
10
15
0whereas I am expecting:
1
3
6
10
15
15My bash version: (4 Replies)
Discussion started by: meharo
4 Replies
6. Shell Programming and Scripting
I was trying to write a simple script which will read a text file and count the number of vowels in the file. My code is given below -
#!/bin/bash
file=$1
v=0
if
then
echo "$0 filename"
exit 1
fi
if
then
echo "$file not a file"
exit 2
fi
while read -n... (14 Replies)
Discussion started by: linux_learner
14 Replies
7. UNIX for Dummies Questions & Answers
Hi. I am trying to start a script on my router that will execute even if i log off. To execute the script I write:
nohup ./dslconnection > dslstat.out 2>&1 &
It starts the job:
21968 admin 1604 S /bin/ash ./dslconnection
The problem is that when I log back in the job has been... (6 Replies)
Discussion started by: sebcou
6 Replies
8. Shell Programming and Scripting
Hi,
Recently I got a .txt file from Mac user. when I try to open it in my Ubuntu machine using cat command it is not displaying any content of file however I can see the content using vi.
Anyone know How to see its content using cat as I have to process it in my shell script.
Thanks in... (4 Replies)
Discussion started by: diehard
4 Replies
9. Shell Programming and Scripting
Hi, I'm having trouble with a simple copy command in a script on HPUX.
I am trying to copy a file and append date & time.
The echo command prints out what I am expecting..
echo "Backing up $file to $file.$DATE.$FIXNUM" | tee -a $LOGFILE
+ echo 'Backing up... (4 Replies)
Discussion started by: Glennyp
4 Replies
10. Shell Programming and Scripting
Following one line of awk code removes first 3 characters from each line but when I run the same code on another linux platform it doesn't work and only prints blank lines for each record. Can anyone please explain why this doesn't work? (31 Replies)
Discussion started by: later_troy
31 Replies
LEARN ABOUT MOJAVE
ppi::token::heredoc5.18
PPI::Token::HereDoc(3) User Contributed Perl Documentation PPI::Token::HereDoc(3)
NAME
PPI::Token::HereDoc - Token class for the here-doc
INHERITANCE
PPI::Token::HereDoc
isa PPI::Token
isa PPI::Element
DESCRIPTION
Here-docs are incredibly handy when writing Perl, but incredibly tricky when parsing it, primarily because they don't follow the general
flow of input.
They jump ahead and nab lines directly off the input buffer. Whitespace and newlines may not matter in most Perl code, but they matter in
here-docs.
They are also tricky to store as an object. They look sort of like an operator and a string, but they don't act like it. And they have a
second section that should be something like a separate token, but isn't because a strong can span from above the here-doc content to below
it.
So when parsing, this is what we do.
Firstly, the PPI::Token::HereDoc object, does not represent the "<<" operator, or the "END_FLAG", or the content, or even the terminator.
It represents all of them at once.
The token itself has only the declaration part as its "content".
# This is what the content of a HereDoc token is
<<FOO
# Or this
<<"FOO"
# Or even this
<< 'FOO'
That is, the "operator", any whitespace separator, and the quoted or bare terminator. So when you call the "content" method on a HereDoc
token, you get '<< "FOO"'.
As for the content and the terminator, when treated purely in "content" terms they do not exist.
The content is made available with the "heredoc" method, and the name of the terminator with the "terminator" method.
To make things work in the way you expect, PPI has to play some games when doing line/column location calculation for tokens, and also
during the content parsing and generation processes.
Documents cannot simply by recreated by stitching together the token contents, and involve a somewhat more expensive procedure, but the
extra expense should be relatively negligible unless you are doing huge quantities of them.
Please note that due to the immature nature of PPI in general, we expect "HereDocs" to be a rich (bad) source of corner-case bugs for quite
a while, but for the most part they should more or less DWYM.
Comparison to other string types
Although technically it can be considered a quote, for the time being "HereDocs" are being treated as a completely separate "Token"
subclass, and will not be found in a search for PPI::Token::Quote or "PPI::Token::QuoteLike objects".
This may change in the future, with it most likely to end up under QuoteLike.
METHODS
Although it has the standard set of "Token" methods, "HereDoc" objects have a relatively large number of unique methods all of their own.
heredoc
The "heredoc" method is the authoritative method for accessing the contents of the "HereDoc" object.
It returns the contents of the here-doc as a list of newline-terminated strings. If called in scalar context, it returns the number of
lines in the here-doc, excluding the terminator line.
terminator
The "terminator" method returns the name of the terminating string for the here-doc.
Returns the terminating string as an unescaped string (in the rare case the terminator has an escaped quote in it).
TO DO
- Implement PPI::Token::Quote interface compatibility
- Check CPAN for any use of the null here-doc or here-doc-in-s///e
- Add support for the null here-doc
- Add support for here-doc in s///e
SUPPORT
See the support section in the main module.
AUTHOR
Adam Kennedy <adamk@cpan.org>
COPYRIGHT
Copyright 2001 - 2011 Adam Kennedy.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
perl v5.18.2 2011-02-25 PPI::Token::HereDoc(3)