zsh-users
 help / color / mirror / code / Atom feed
From: guyzmo <guyzmo+zsh@m0g.net>
To: zsh-users@zsh.org
Subject: Re: I/O edirection and dd
Date: Sun, 24 Apr 2016 13:22:02 +0200	[thread overview]
Message-ID: <20160424112202.fre5vs6axp5grofy@BuGz> (raw)
In-Reply-To: <20160424095342.GA11812@solfire>

Hello Meino,

this question is not diretcly zsh related so this list is not the place
to ask that. It would be a better fit for a stackexchange-like forum
(either stackoverflow, or superuser, or unix stackoverflow). But anyway,
I'm giving you an answer inline.

On Sun, Apr 24, 2016 at 11:53:42AM +0200, Meino.Cramer@gmx.de wrote:
> with the pipe
> 
>     cat verylongfile | dd count=512 | file -
> 
> I want to get the type of file without reading it completly.
[...]
> How can I acchieve what I want?

First, you're doing a useless use of cat, as dd can have its input file
defined using the 'if=' argument. Then the byte count is way too high,
as file only needs the first few bytes to determine type of a file.
Finally, you can get rid of useless output by redirecting stderr from dd
into the null chadev, but if you don't it's not preventing file to do
its job. So here you go:

    % dd if=ascii_file.txt count=10 | file -
    10+0 records in
    10+0 records out
    5120 bytes (5.1 kB) copied, 6.7592e-05 s, 75.7 MB/s
    /dev/stdin: ASCII text

or for the less chatty version:

    % dd if=ascii_file.txt count=10 2> /dev/null | file -
    /dev/stdin: ASCII text

and there you go!

HTH,

-- 
Guyzmo


  reply	other threads:[~2016-04-24 11:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-24  9:53 Meino.Cramer
2016-04-24 11:22 ` guyzmo [this message]
2016-04-24 11:22 ` lilydjwg
2016-04-24 17:10   ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160424112202.fre5vs6axp5grofy@BuGz \
    --to=guyzmo+zsh@m0g.net \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).