Thanks ad39311
I'd done a bit more research since, too, and found the same answer you gave - I'm including it here so people are linked to a possible other source of answers:
The answer is here...
In MS Word 2003, I'm writing a document that involves linking to two Excel spreadsheets.
\\bp1ldcvi012\darren$\WORK\Migration\Apps.xls
\\bp1ldcvi012\MISC2\Apps Support Team\Middle Office\_General\Supported Apps.xls
These links work as I create them (I can ctrl-click them and the spreadsheets...
Hi PHV,
What I meant was:
$ FOO=$(find * -prune -type -f -name file_does_not_exist)
$ echo $FOO|od -c
0000000 \n
0000001
$
That new-line is proving to be a pain.
There is a problem with this method:
if there are no files found, FILE_LIST="\n", which is a pain. Sure, I can test for this and remove it later, but it would be neater if there is a way to cause FILE_LIST="" if find finds no files?
I am writing a script that:
- does an rsh to various unix boxes, and on each one...
- list the files in a given directory that begin with certain letters
I currently do it the following way, which seems like a cludge and I was hoping if any of you had a better suggestion?
I use
"find * -prune...
Hi hokky,
man odhas a pretty neat table that I've been referring to since I started this role at the end of March just to keep a ready-reckoner of "Unix=lf, Dos=cr/lf, cr=\015=^M" - I didn't have to look those up as I wrote that so I guess it's stuck now :)
In my analysis of what the various...
Hi again p5wizard
Sorry, was answering a different train of thought :)
Completely understand the use of functions.
Thanks for your suggestion.
(as an aside - this legacy code I'm working on in parallel is heavily functioned, and uses lines like the "if [[ $AR = 1 ]]" which leaves me asking...
Hi p5wizard,
There's various schools of thought I've encountered at my various client sites about the use of comments, and the school of thought they have here is that comments are not there to teach the reader unix commands, they're there to explain the business reasons behind code logic.
So...
Hi hokky,
I'm developing a script that analyses non-unix files (that end up on a unix file system) so I've encountered exactly the same problem.
Commands like sed, awk and grep expect a file in unix format, so they expect their lines to end with a line feed.
I'm constantly looking into the...
Oops! Sorry, my careless copying.
I should have put two spaces in between ## and *
This works:
$ cat file
020 PPP GB 123 ABC G XXX
$ VALUE=$(cut -c10-25 file) ; VALUE=${VALUE%% *} ; echo "$VALUE" | od -ta
0000000 G B sp 1 2 3 sp A B C sp G lf
0000015
$
Also, for...
I'd do it all in perl if I had my way :)
It's a requirement to do the bulk of the script in ksh, and to make it highly readable for the non-unix BAs and the non-unix production support staff.
Also, my awk/nawk is non-existant. Is it possible to combine the cut + sed to strip leading&trailing...
Hi,
I'm using ksh and am analysing reports which have fixed column widths (candidate for the cut command).
The values in that particular column might not be as wide as the column, so
VALUE=$(cut -c10-25 file)
might set VALUE="GB 123 ABC G "
and what I want is VALUE="GB 123 ABC G"
(so I want...
yeah that worked. Thanks :)
> i=0;time while [[ $i -lt 100000 ]]; do ((i+=1));done
real 0m1.44s
user 0m1.44s
sys 0m0.00s
> i=0;time while [ $i -lt 100000 ]; do ((i+=1));done
real 0m1.95s
user 0m1.95s
sys 0m0.00s
Hi, the ((i++)) doesn't appear to work on my ksh:
master # i=0; time while [[ $i -lt 100000 ]]; do ((i++)); done
ksh: i++: more tokens expected
master # ps -fp$$
UID PID PPID C STIME TTY TIME CMD
master 12211 12210 0 11:24:27 pts/18 0:00 -ksh
# type [[
[[ is a reserved shell keyword
# type [
[ is a shell builtin
# type test
test is a shell builtin
So if it's all internal, what, really, is the difference between a "reserved shell keyword" and a "shell builtin" and does it really matter for efficiency purposes?
I'm testing for the existence of files that begin with, say, "gene" and have 8 characters in the filename.
So gene????
This will not work:
if [[ -f gene???? ]]
because [[/]] does not allow wildcard expansion.
So I'm currently using
if [ -f gene???? ]
But it would be nice to keep this test...
In line with Ferherke's tip to try to get nawk to do as much work as possible, I replaced:
OUT_TEXT_DATE=$(grep 'AP BALANCES AS AT' $FILE_NAME | nawk '{print $6} | head -1'
with
OUT_TEXT_DATE=$(nawk '/AP BALANCES AS AT/{print $6}' $FILE_NAME | head -1)
(I'm not a nawk person so I'm learning...
Although not an exact answer for your specific problem, I'm having to handle similar issues with the files input to me.
So thought I'd just mention the things I am dealing with at the moment in case it gives you any further ideas:
I'm writing a Unix korn shell script to analyse text files. So...
Another solution, which I think is closer to what I want:
nawk 'sub(",",""){print $6, $7, $8}'
Got this function from the O'Reilly "sed & awk" book by Dale Dougherty
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.