Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: I/O edirection and dd
- X-seq: zsh-users 21485
- From: guyzmo <guyzmo+zsh@xxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: I/O edirection and dd
- Date: Sun, 24 Apr 2016 13:22:02 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=simple/simple; d=m0g.net; s=mail; t=1461496936; bh=PponNXuZ1P6KKUjkjkpETRp8nUGEq8DKT9Vmi7uHXx4=; h=Date:From:To:Subject:References:In-Reply-To:From; b=ehIBTYxBnvfF4DNbrdfGGOEYcuaFFAlwFukCWtaOOs8Ayxy8XhOfAffiX2Suq1ABd BXTjR1or0VCB780jlDFCPDuC30Bv6V6tQVK4fM4a2BUfS1sey1jvWrOSNLajDi/6dQ w5SlXS9ej5dHFlOWosr4FNPxZCY3+00AL8bLD+/1p8NsP3H39v5GUZbICKngzOod0E J2NZ84vUe1xFopVWVk4ybrvQOGV8N+bS5wQBTDo31PZ/uxplNYxbK1jT8fF27zwBNc Dxk8zx5HTVd2o77jNh1GuMJTh/9mGVJ/HZnCoFeDoWFckjmAONpSCw28QoB5h4SPfc Yj4MMm7hiW4Sw==
- In-reply-to: <20160424095342.GA11812@solfire>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <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@xxxxxx 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author