You are not logged in.
Pages: 1
Is there a write command in shell? It seems like there should be, but I guess most people just use the ">" and "<" symbol. It just seems like it would make things simpler to just use the "|" pipe symbol.
Libertarian Arch Linux User
Offline
How would that make things simpler exactly?
![]()
Offline
Have a look at 'tee', which reads from stdin and writes (or optionally appends) to a file. However, a side effect of this is that it also writes to stdout.
Offline
Is this what you mean?
cat > output-file.txt <<EOT
This is a file. Files are cool.
It is multiline too. How awesome.
EOTLast edited by fukawi2 (2009-10-23 06:01:19)
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
What's EOT? I've only seen that as EOF.
![]()
Offline
What's EOT? I've only seen that as EOF.
Well, it doesn't matter... it could be ABC and still work, but I am guessing he put T for Text instead of F for File... or typo... whatever. ![]()
Offline
Is there a write command in shell? It seems like there should be, but I guess most people just use the ">" and "<" symbol. It just seems like it would make things simpler to just use the "|" pipe symbol.
How is it "easier"? It's people like you who commit cat abuse.
Last edited by ZankerH (2009-10-23 09:08:16)
Offline
What's EOT? I've only seen that as EOF.
EOT = End Of Transmission
EOF = End Of File
They're synonyms, as far as I see. ascii(7) calls it EOT while it's called eof for stty(1), still both mean \x04.
Offline
cat > file
blaha random
text etc...
then ctrl+d to close cat.
Or
echo -e "some random text \n in a file" > file
Offline
I think he means something like this:
$ some command here | write /path/to/fileTo remove the > symbol. Presumably such a command would have an optional argument to have append functionality, removing the >> symbol.
Offline
as already mentioned, 'tee' does this, but it also prints to stdout.
archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson
Offline
What is this obsession with tee?
> write () { dd of="$1" &> /dev/null ; }
> echo some text | write somefile
> cat somefile
some textEdit: Real men use dd or you can just use cat > "$1".
Last edited by fsckd (2009-10-23 16:01:23)
aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies
Offline
What is this obsession with tee?
> write () { dd of="$1" &> /dev/null ; } > echo some text | write somefile > cat somefile some textEdit: Real men use dd or you can just use cat > "$1".
Some of those real men end up with corrupted HDDs when they're not careful ![]()
Archlinux | ratpoison + evilwm | urxvtc | tmux
Offline
OK, so tee is what I was looking for thanks.
I just think it seems like it would make things simpler to use a command, instead of introducing a new symbol, and give you more options.
Libertarian Arch Linux User
Offline
OK, so tee is what I was looking for thanks.
I just think it seems like it would make things simpler to use a command, instead of introducing a new symbol, and give you more options.
Using > means one less process compared to cat/dd abuse.
I hereby nominate the OP for the UUOC award.
Offline
I hereby nominate the OP for the UUOC award.
I'm pretty sure he never once mentioned cat :P
Offline
Kind of off topic but does anyone know if tee existed in the old UNIX days? or is it a newer Unix-like app?
![]()
Offline
It is a standard UNIX command (see Single UNIX Specification) and found in a whole host of UNIX derivatives (plus other platforms). Though I couldn't find exactly when it originated.
Offline
Kind of off topic but does anyone know if tee existed in the old UNIX days? or is it a newer Unix-like app?
I've look around all over also, no indication of where it first appeared, and I even looked here. My guess, it's a newer Unix-like app.
Offline
I can verify it was on Minix 1 (1980's). Here is the man page (very short!):
Command: tee - divert standard input to a file
Syntax: tee [-ai] file ...
Flags: -a append to the files, rather than overwriting
-i ignore interrupts
Examples: cat file1 file2 | tee x # Save and display two files
pr file | tee x | lpr # Save the output of pr on x
Tee copies standard input to standard output. It also makes copies on
all the files listed as arguments.Edit: It looks like it is an old UNIX command. You can find its manual entry for Version 7 UNIX under volume 1, section 2 here or here.
Last edited by fsckd (2009-10-24 13:10:44)
aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies
Offline
I just think it seems like it would make things simpler to use a command, instead of introducing a new symbol, and give you more options.
But then instead you are introducing a new command. And you would still need to use | so it cannot really be for the reason that alphanumeric combinations are easier to remember than any other character...
Oh well, to each their own I guess...
Last edited by tlvb (2009-10-24 14:20:12)
I need a sorted list of all random numbers, so that I can retrieve a suitable one later with a binary search instead of having to iterate through the generation process every time.
Offline
Pages: 1