![]() |
|
|
#12 |
|
Nov 2003
E2616 Posts |
`foo` is the stdout of running function "foo". It's consumed by "if".
It's the same like z=`foo` # nothing is being printed, z='aa' To get the "aaUnequal" output, execute foo once more: foo if [ `foo` = 'aa' ]; then ... |
|
|
|
|
|
#13 | ||
|
Aug 2006
135338 Posts |
Quote:
Quote:
Because I didn't know how to access the return value I was using the backtick hack (passing the whole comparison rather than the result of the comparison), but that won't be an issue anymore. Honestly I still don't understand how to use od. And I'm not sure what you mean by string comparisons, since I'm doing string comparisons now. |
||
|
|
|
|
|
#14 |
|
Nov 2003
2·1,811 Posts |
(2) was directed to Alex in post #9, not to you.
(3) Try "od -aN4 a.png", it returns "P N G" with spaces. You can remove spaces with bash (or sed) and get "PNG". Ditto for jpg (look for JFIF), with "-aN10". You will have to select a suitable max number of bytes to find the magic number. But that's exactly what "file" does: z=`file $input_file` and check $z for all doc types you want to handle. Type "man file" for details. Magic numbers are kept in another file that you can modify if you want to add new file types. No need to rediscover the wheel. :-) Last fiddled with by Kosmaj on 2009-03-25 at 07:50 |
|
|
|
|
|
#15 | ||
|
Aug 2006
3·1,993 Posts |
Ah! No wonder I was confused. I pick up programming languages much faster than human subtleties (doubly so on forums where there's no intonation).
Quote:
Quote:
Any suggestions on where to go from here? Any other fun toys I should learn? I've been using regular expressions longer than linux, so don't say grep. But as you might imagine, most things are still mysterious to me. I have two decades of experience on DOS/Windows but only one month of experience on Ubuntu...Edit: I don't think I told you that I appreciated your efforts to explain things to me. Thanks: it all makes sense now! Last fiddled with by CRGreathouse on 2009-03-26 at 02:57 |
||
|
|
|
|
|
#16 |
|
May 2008
3×5×73 Posts |
See if you can make a Mersenne prime-prover using only Bash built-in commands.
|
|
|
|
|
|
#17 | ||
|
"Nancy"
Aug 2002
Alexandria
2,467 Posts |
Quote:
Note to self: Quote:
|
||
|
|
|
![]() |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Scripts thread | bsquared | YAFU | 4 | 2012-10-21 19:45 |
| the scripts thread | Mini-Geek | Conjectures 'R Us | 52 | 2012-05-29 21:43 |
| aliquot escape | firejuggler | Aliquot Sequences | 26 | 2012-01-19 08:15 |
| High-altitude driver escape | fivemack | Aliquot Sequences | 1 | 2011-04-24 09:34 |
| DPGraph 2D/3D scripts | nibble4bits | Lounge | 0 | 2008-01-16 17:05 |