jcl
Linux Experts-
Content Count
1299 -
Joined
-
Last visited
Content Type
Profiles
Forums
Calendar
Everything posted by jcl
-
They work fine here, with or without the calls to close() ~/src/bt $ grep close first.cc second.cc ~/src/bt $ g++ -o first first.cc ~/src/bt $ g++ -o second second.cc ~/src/bt $ ./first Sales Person name input: foo value of sales for the week: 12 ~/src/bt $ ./second foo $12 ~/src/bt $ The files are closed implicitly when the program exits, by the fstream dtor, the runtime cleanup code, or the kernel, so there shouldn't be a problem if they're separate programs. In a single program you'd have to verify that a single file can opened and manipulated via two different streams pointing in di
-
sed's -i option enables in-place editing, with optional backups.
-
while (( userInput = Â promptUser ( "Enter Salary or -1 to quit: ")) != -1 ); Â Â <-- stray semicolon
-
EOF is ^D. ^C sends an interrupt signal. Well, you can, but it calls for a slightly a more interesting approach to input prompts.
-
for (int x = 0; x <=9; x++); <--- stray semicolon
-
It's possible that the mix of filetypes in your Ubuntu and Gentoo installs is very different. Generally speaking I would expect that as a proportion of non-text files (executables, libraries, images, etc) went up, the compression ratio would go down (that it, toward 1:1). Ubuntu likely has a much larger proportion of binaries than Gentoo. You may want to poke around your Gentoo install and see if it has any large stashes of the source code that are compressing well. The build directories in /var/tmp/portage/, for example, can eat a tremendous amount of disk space in some circumstances, but
-
Here's something to aim for: ~ $ ll /mnt/media/jcl/jcl.tar -rw-r--r-- 1 jcl users 7759513600 Mar 17 15:58 /mnt/media/jcl/jcl.tar
-
That's an... unusual thing to do. The only hostname that should be assigned to 127.0.0.1 by default is localhost, and it shouldn't be reassigned carelessly. There's a risk that something will break if you use 127.0.0.0. For example, if your system happens to treat that as a broadcast address (as Linux does), there could be some weirdness (on my system, pinging 127.0.0.0 (or a hostname assigned to that address) results in a request that you specify a broadcast ping). It should still work but you never know. I've never seen a browser on any platform attempt to tamper with hosts. For those w
-
Java.com should have a download link on the front page (top right) that will take you right to the package. If that doesn't work, here is the most direct link to the main Java site that I know works. Select "JRE 5.0 Update 3" (third item down), accept the license, then select either "Windows Offline Installation" or "Windows Online Installation, Multi-language" (top two items), and then be grateful you aren't a Java developer because this is downright easy compared to getting the development packages It's an old version of the platform. Microsoft's JRE (Java Runtime Environment) supports e
-
You'd have to ask them It wouldn't surprise me if it was habitual and the author didn't notice the inconsistency. Strictly there was no need to use braces at all in that script. In the absence of braces the shell is supposed to use the longest valid variable name. '/' isn't a valid character in a name, so there's no chance of misparsing the whole path as a variable. Still, the braces are the recommended form.
-
Debian has an archaic, but usable, textual installer. Gentoo doesn't have an installer, so I'm not sure what you're implying about FreeBSD
-
The echo built-in ignores it by default, but it is supported via -e.
-
Unix uses backslash for two purposes: to disable special interpretation of some characters (quotation marks, spaces, etc) and to enable special interpretation of other characters. For example, '\n' is often interpreted as a newline character and \t as a (horizontal) tab. In your example, '\c' is supposed to prevent echo from printing a trailing newline. However, that's a non-standard feature and support varies from shell to shell and platform to platform. bash and GNU echo will enable backslash sequence processing if you pass the '-e' option to echo. echo -e "Enter the name of the director
-
By the way, if your book doesn't mention it, that could be rewritten to use shell arithmetic expansion: #!/bin/bash x=0 while [ $x -lt 10 ] do echo $x x=$(($x + 1)) done or even: #!/bin/bash x=0 while [ $x -lt 10 ] do echo $((x++)) done Not that I recommend deviating from the book.
-
Typo. 'x' is capitalized on the sixth line.
-
Indeed. Those of you are concerned about this sort of thing might want take a look at the effect GoogleGroups, nee DejaNews, has had on Usenet. There you have over a billion posts by millions of authors stretching back 24 years. There were a lot of people who participated in Usenet believing their posts were ephemeral and only much later discovered that they were being archived and indexed. The result is a vast amount of increadibly embarrassing information at your fingertips. There have been great debates about privacy, anonymity, and intellectual property that directly address most of
-
sorry you already answered that(I missed it)[/q] I think I added that in an edit while you were posting. One of these days I'll learn to write my posts all at once instead of doings edits for half an hour
-
Dunno, I don't do much shell scripting.
-
Among other things. After variable substitution $ gg=""; [ -n $gg ]; echo $? becomes $ [ -n ]; echo $? and 'test' is defined such that if there's only one argument the exit status is 0 if that argument is non-null and 1 otherwise. -n is treated as a regular argument rather than operator in this case. Not sure if this is documented but it's POSIX behavior. It will work if you quote '$gg' in the test to ensure that you get at least the empty string $ gg=""; [ -z "$gg" ]; echo $? 0 $ gg=""; [ -n "$gg" ]; echo $? 1
-
Far be it from me to tell you not to hate Google -- I've muttered my share of obscenities at them for GoogleGroups and GoogleNews -- but the individual sites are responsible for what's indexed. Google nominally obeys the robot exclusion protocol, so a robots.txt file containing User-Agent: * Disallow: / should prevent the GoogleBot (and every other search bot) from indexing a site. If it doesn't, any sort of authentication will stop it. Otherwise Google does what any good search engine does and indexes (almost) every page it can find. Try running your handle though AlltheWeb, Yahoo!, or e
-
$ set will print all shell variables, including those not exported. $ printenv or $ env will print exported variables. The latter will also allow you to modify the environment before issuing a command. $ echo one In the form ${one:-two}, 'one' is the name of a variable, so the value won't be 'one' unless you happen to have $ one=one somewhere.
-
The BSDs use more lenient implementations of sh (BSD sh for Free and Net, pdksh for Open). Strict POSIX conformance has never been a very high priority for them.
-
POSIX only permits shell function names containing alphanumeric characters and underscores; hyphens and other punctuation are verboten. When bash is invoked as sh it tries to strictly follow POSIX and historical sh; apparently that extends to the naming restrictions. Addendum: took me a while to find it, but that is documented behavior in the Bash POSIX Mode section of the manual, item 15. For details $ info bash 'Bash Features' 'Bash POSIX Mode'
-
exit was the first thing I considered too The second one was a good idea; too bad the shell is a bit inconsistent about how it handles variables. Many rather useful variables are untouchable, often because of syntax issues.