Reputation
2,760
Top tag
Next privilege 3,000 Rep.
Cast close & reopen votes
Badges
5 22
Newest
 Custodian
Impact
~54k people reached

Jul
26
comment A question for old unix gurus or simply older SVR4 users: backup output
Somehow it seems to me that the statements "This backup command works OK" and "I have no idea where it backed up my files" go together like "I just bought a beautiful (and very expensive) suit of clothes" and "In fact, it's so transcendent that I can't even see it (or feel it)."
Jul
26
comment ssh over unix pipe or pty device
Are you saying "I have this", or are you asking "Could I create this?  What would happen if I did?" If you have it, what system do you have it on, and what has your prior independent search of its documentation told you? If you're hypothesizing it, tell us more about what you're thinking. Please do not respond in comments; edit your question to make it clearer.
Jul
26
answered Piping contents of multiple files between programs while keeping contents separate
Jul
26
answered How to create a zip of directories -mtime -150
Jul
23
comment Convert ls -l output format to chmod format
@StéphaneChazelas: OK, you're talking about cas's answer again now, right?  He's taking the "lazy" approach of using decimal arithmetic to construct a string that looks like an octal number.  Note that all his step values (4000, 2000, 1000, 400, 200, 100, 40, 20, and 10) are decimal numbers.  But, since there are no 8's or 9's, and no way to get more than 7 in any decimal position, he can pull of the charade. … … … … … … … … (This comment is a response to a Stéphane Chazelas comment that disappeared.)
Jul
23
comment Merge two-columns files into one file
(The five-minute editing window ran out.)  By the way, < filename | command isn't going to work.  Try < filename  command (omitting the |) or command < filename (putting the I/O redirection at the end of the command).  In fact, most commands (including cut) will read from file(s) whose name(s) are passed as arguments, so you can say simply command filename.
Jul
23
comment Merge two-columns files into one file
BTW, < filename | command isn't going to work.  Try < filename  command (leaving out the |) or command < filename (putting the I/O redirection at the end of the command).
Jul
23
comment Merge two-columns files into one file
steve's answer demonstrates that your problem statement is unclear.  Please describe more clearly what you mean by "merge" and show two or more sample files (it's probably sufficient to show only two or three lines from each) and then show the desired output.  BTW, are you guaranteeing that all the files are the same length (if that's appropriate)?
Jul
23
comment Convert ls -l output format to chmod format
@StéphaneChazelas: OK, I said #!/bin/sh and then used a few bashisms.  Oops.  But you missed a couple: $(( variable++ )) and $(( number ** number )) don’t seem to be POSIX either (the Standard doesn’t mention ** at all, and is squirrelly on ++ and --).  Conversely, I didn’t use [[…]]; that appears only in cas’s answer, which I quoted from here.  Also, my answer does handle ‘l’ and ‘L’, and I already pointed out the fact that cas’s answer doesn’t.
Jul
23
revised Convert ls -l output format to chmod format
Added POSIX-compliant (non-bash-specific) version, and more words.
Jul
20
comment How can the standard input of one program be passed as an arg to another?
That can be abbreviated/automated to prog1  input_file $(tty); which is generally going to be equivalent to prog1  input_file /dev/tty.  But this approach assumes that the goal is to display the output of prog1 (i.e., in the terminal), and that is not what the question is asking (see the comments on terdon's answer for some clarification on the meaning of the question).
Jul
20
comment How can the standard input of one program be passed as an arg to another?
And let me backpedal once more: if prog2 writes to stdout, prog1 input_file >( cat ) | prog2 is better than prog1 input_file >( prog2 ), because the cat form waits for prog2 to complete (i.e., before the shell issues the next prompt or goes on to the next command (e.g., after ; or &&)), while the cat-less form waits only for prog1 to complete.  Also, after the cat form, $? is the exit status from prog2, whereas, in the other, $? is the exit status from prog1.  (You pays your money and you takes your choice.)
Jul
20
comment How can the standard input of one program be passed as an arg to another?
Of course, if you just want to display the output of prog1, you can use prog1 input_file /dev/tty, or jas's idea, prog1 input_file $(tty).
Jul
20
comment How can the standard input of one program be passed as an arg to another?
(Cont’d) …  And I want to retract what I said in my first comment: if TiCPU’s answer doesn’t work (e.g., because /dev/stdout doesn’t exist), Digital Trauma’s answer may be the only (or at least the best) answer, and calling it a UUOC, while arguably, technically true, was a little harsh, because, while prog1 input_file >(  cat  ) | prog2 can be abbreviated to prog1 input_file >( prog2 ), the cat form is (again, arguably) clearer.
Jul
20
comment How can the standard input of one program be passed as an arg to another?
@DigitalTrauma: Yeah, sorry; I was just in the process of typing a retraction.  But first: The question seems (to me) to be asking how to handle some (hypothetical) program (nominally, pdftotext) that insists on doing open(argv[1], O_RDONLY) and open(argv[2], O_CREAT|O_WRONLY), and doesn’t default to reading stdin or writing stdout (not even if given an arg of -).  And TiCPU and Digital Trauma both wrote decent answers to that question.  … (Cont’d)
Jul
20
comment How can the standard input of one program be passed as an arg to another?
I don't see where the OP chose cat.  Somebody posted a semi-answer featuring a UUOC in a comment, and the OP (who didn't understand quite how to apply it) replied that it didn't work for him.  (And, of course, I realize that commands that don't even include cat cannot be UUOCs.)
Jul
20
comment How can the standard input of one program be passed as an arg to another?
When is cat <( command ) ever useful?  That looks like a UUOC.  I think TiCPU's answer is correct (although not spelled out clearly): pdftotext "C BY K&R.pdf" /dev/stdout.  (I guess Digital Trauma's answer would work, although it's also a UUOC.)
Jul
18
comment How to create a zip of directories -mtime -150
Do you have directories within directories (e.g., dir1/dir17)?  If dir1 was modified 140 days ago, but dir1/dir17 was modified 160 days ago, do you want the contents of dir17 to be zipped, or just the first-level files in dir1?
Jul
17
comment What's the story behind command file's suggestion?
@EvgenyVereshchagin: OK, that's sort of relevant to the topic — but not much.  Or are you making a point?
Jul
16
revised How does one inspect the directory structure information of a unix/linux file?
Identified some good ol' unices.