Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

TRANSACTION CANCELLED - FARECARD RETURNED


devel / comp.unix.shell / I can't cut fields from "fdisk -l"

SubjectAuthor
* I can't cut fields from "fdisk -l"Ottavio Caruso
+- Re: I can't cut fields from "fdisk -l"hymie!
+* Re: I can't cut fields from "fdisk -l"Janis Papanagnou
|`* Terminal just hangs (Was: I can't cut fields from "fdisk -l")Kenny McCormack
| `* Re: Terminal just hangs (Was: I can't cut fields from "fdisk -l")Janis Papanagnou
|  `* Re: Terminal just hangs (Was: I can't cut fields from "fdisk -l")Kenny McCormack
|   +- Re: Terminal just hangs (Was: I can't cut fields from "fdisk -l")Grant Taylor
|   `- Re: Terminal just hangs (Was: I can't cut fields from "fdisk -l")Janis Papanagnou
+- Re: I can't cut fields from "fdisk -l"Kenny McCormack
`- Re: I can't cut fields from "fdisk -l"Wayne

1
I can't cut fields from "fdisk -l"

<t11tbd$qh3$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=5095&group=comp.unix.shell#5095

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ottavio2...@yahoo.com (Ottavio Caruso)
Newsgroups: comp.unix.shell
Subject: I can't cut fields from "fdisk -l"
Date: Fri, 18 Mar 2022 12:18:52 +0000
Organization: A noiseless patient Spider
Lines: 61
Message-ID: <t11tbd$qh3$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 18 Mar 2022 12:18:53 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="48027d78ab1c47cb1a6936c21bd16cd3";
logging-data="27171"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/aRC+DT9tWdeu6WH8x1/rVcHkfeRRggos="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.0.3
Cancel-Lock: sha1:ngfofVk4mSWdXlapAGSZkClVsxk=
X-No-Archive: yes
Content-Language: en-GB
 by: Ottavio Caruso - Fri, 18 Mar 2022 12:18 UTC

Hi,

$ sudo fdisk -l
Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Disk model: HITACHI HTS72505
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 6EC2F34F-F0E0-44EB-AF31-94969532B3A5

Device Start End Sectors Size Type
/dev/sda1 2048 1023999 1021952 499M Windows recovery environment
/dev/sda2 1024000 1226751 202752 99M EFI System
/dev/sda3 1226752 1259519 32768 16M Microsoft reserved
/dev/sda4 1259520 103657471 102397952 48.8G Microsoft basic data
/dev/sda5 103657472 206057471 102400000 48.8G Linux filesystem
/dev/sda6 223012864 877277183 654264320 312G Microsoft basic data
/dev/sda7 206057472 223012863 16955392 8.1G Linux swap
/dev/sda8 877277184 976773119 99495936 47.5G Linux filesystem

Partition table entries are not in disk order.

$ sudo fdisk -l |tail -n 10|head -n 8
/dev/sda1 2048 1023999 1021952 499M Windows recovery environment
/dev/sda2 1024000 1226751 202752 99M EFI System
/dev/sda3 1226752 1259519 32768 16M Microsoft reserved
/dev/sda4 1259520 103657471 102397952 48.8G Microsoft basic data
/dev/sda5 103657472 206057471 102400000 48.8G Linux filesystem
/dev/sda6 223012864 877277183 654264320 312G Microsoft basic data
/dev/sda7 206057472 223012863 16955392 8.1G Linux swap
/dev/sda8 877277184 976773119 99495936 47.5G Linux filesystem

So far, so good.

Now, I only want fields 1 (Device), 5 (size) and 6 (Type):

$ sudo fdisk -l |tail -n 10|head -n 8|cut -f 1,5,6 -d" "
/dev/sda1
/dev/sda2 1024000
/dev/sda3 1226752
/dev/sda4 1259520 103657471
/dev/sda5 102400000 48.8G
/dev/sda6 654264320
/dev/sda7 16955392
/dev/sda8 99495936

What am I doing wrong?

--
Ottavio Caruso

Re: I can't cut fields from "fdisk -l"

<slrnt38vp7.ekm.hymie@nasalinux.net>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=5096&group=comp.unix.shell#5096

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!news.freedyn.de!newsreader4.netcologne.de!news.netcologne.de!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.ams4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx13.iad.POSTED!not-for-mail
Newsgroups: comp.unix.shell
From: hym...@nasalinux.net (hymie!)
Subject: Re: I can't cut fields from "fdisk -l"
References: <t11tbd$qh3$1@dont-email.me>
Organization: Eric Conspiracy Secret Labs
User-Agent: slrn/pre1.0.4-6 (Linux)
Message-ID: <slrnt38vp7.ekm.hymie@nasalinux.net>
Lines: 25
X-Complaints-To: abuse@usenet-news.net
NNTP-Posting-Date: Fri, 18 Mar 2022 12:46:31 UTC
Date: Fri, 18 Mar 2022 12:46:31 GMT
X-Received-Bytes: 1431
 by: hymie! - Fri, 18 Mar 2022 12:46 UTC

In our last episode, the evil Dr. Lacto had captured our hero,
Ottavio Caruso <ottavio2006-usenet2012@yahoo.com>, who said:

> $ sudo fdisk -l |tail -n 10|head -n 8
> /dev/sda1 2048 1023999 1021952 499M Windows recovery environment

Notice that there are multiple spaces between /dev/sda1 and 2048

> $ sudo fdisk -l |tail -n 10|head -n 8|cut -f 1,5,6 -d" "
> /dev/sda1

cut sees each of those spaces in the above line as a delimiter for an
empty field

> What am I doing wrong?

You need something like

$ sudo fdisk -l |tail -n 10|head -n 8| \
perl -ane 'print join(" ",@F[0,4,5]),"\n";'

I'm sure awk will do it, but I don't know awk as well as I know perl.
And I'm not sure my perl is correct either.

--hymie! http://nasalinux.net/~hymie hymie@nasalinux.net

Re: I can't cut fields from "fdisk -l"

<t11v5e$1kf$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=5097&group=comp.unix.shell#5097

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: I can't cut fields from "fdisk -l"
Date: Fri, 18 Mar 2022 13:49:49 +0100
Organization: A noiseless patient Spider
Lines: 65
Message-ID: <t11v5e$1kf$1@dont-email.me>
References: <t11tbd$qh3$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 18 Mar 2022 12:49:50 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f1aa0ff20907ebe22a9eba7bb989115b";
logging-data="1679"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/JFFG0BqgVwS+BdjGr2EgZ"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:zgbm5BUXSF83beQ9WV5wKeRFDEw=
In-Reply-To: <t11tbd$qh3$1@dont-email.me>
 by: Janis Papanagnou - Fri, 18 Mar 2022 12:49 UTC

On 18.03.2022 13:18, Ottavio Caruso wrote:
> Hi,
>
>
> $ sudo fdisk -l
> Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
> Disk model: HITACHI HTS72505
> Units: sectors of 1 * 512 = 512 bytes
> Sector size (logical/physical): 512 bytes / 4096 bytes
> I/O size (minimum/optimal): 4096 bytes / 4096 bytes
> Disklabel type: gpt
> Disk identifier: 6EC2F34F-F0E0-44EB-AF31-94969532B3A5
>
> Device Start End Sectors Size Type
> /dev/sda1 2048 1023999 1021952 499M Windows recovery environment
> /dev/sda2 1024000 1226751 202752 99M EFI System
> /dev/sda3 1226752 1259519 32768 16M Microsoft reserved
> /dev/sda4 1259520 103657471 102397952 48.8G Microsoft basic data
> /dev/sda5 103657472 206057471 102400000 48.8G Linux filesystem
> /dev/sda6 223012864 877277183 654264320 312G Microsoft basic data
> /dev/sda7 206057472 223012863 16955392 8.1G Linux swap
> /dev/sda8 877277184 976773119 99495936 47.5G Linux filesystem
>
> Partition table entries are not in disk order.
>
>
>
>
> $ sudo fdisk -l |tail -n 10|head -n 8
> /dev/sda1 2048 1023999 1021952 499M Windows recovery environment
> /dev/sda2 1024000 1226751 202752 99M EFI System
> /dev/sda3 1226752 1259519 32768 16M Microsoft reserved
> /dev/sda4 1259520 103657471 102397952 48.8G Microsoft basic data
> /dev/sda5 103657472 206057471 102400000 48.8G Linux filesystem
> /dev/sda6 223012864 877277183 654264320 312G Microsoft basic data
> /dev/sda7 206057472 223012863 16955392 8.1G Linux swap
> /dev/sda8 877277184 976773119 99495936 47.5G Linux filesystem
>
>
> So far, so good.
>
>
> Now, I only want fields 1 (Device), 5 (size) and 6 (Type):
>
>
> $ sudo fdisk -l |tail -n 10|head -n 8|cut -f 1,5,6 -d" "
> /dev/sda1
> /dev/sda2 1024000
> /dev/sda3 1226752
> /dev/sda4 1259520 103657471
> /dev/sda5 102400000 48.8G
> /dev/sda6 654264320
> /dev/sda7 16955392
> /dev/sda8 99495936
>
>
> What am I doing wrong?

You are using the wrong tool; ignore cut, use awk.

awk '{print $1,$5,$6}'

Janis

Re: I can't cut fields from "fdisk -l"

<t11vgm$1pk24$1@news.xmission.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=5098&group=comp.unix.shell#5098

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: I can't cut fields from "fdisk -l"
Date: Fri, 18 Mar 2022 12:55:50 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <t11vgm$1pk24$1@news.xmission.com>
References: <t11tbd$qh3$1@dont-email.me>
Injection-Date: Fri, 18 Mar 2022 12:55:50 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="1888324"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Fri, 18 Mar 2022 12:55 UTC

In article <t11tbd$qh3$1@dont-email.me>,
Ottavio Caruso <ottavio2006-usenet2012@yahoo.com> wrote:
....
>$ sudo fdisk -l |tail -n 10|head -n 8|cut -f 1,5,6 -d" "
>/dev/sda1
>/dev/sda2 1024000
>/dev/sda3 1226752
>/dev/sda4 1259520 103657471
>/dev/sda5 102400000 48.8G
>/dev/sda6 654264320
>/dev/sda7 16955392
>/dev/sda8 99495936

I couldn't make heads nor tails out of your proposal, but here's how I'd do
it:

# fdisk -l | gawk '/^\/dev\// { print $1,$5,$6 }'

>What am I doing wrong?

Everything.

P.S. Nitpickers note: Some genius will want to write in to tell me that I
don't need gawk - that any old AWK will do. This is true, but irrelevant,
for a half-dozen or so reasons. So, don't bother.

--
Men rarely (if ever) manage to dream up a God superior to themselves.
Most Gods have the manners and morals of a spoiled child.

Terminal just hangs (Was: I can't cut fields from "fdisk -l")

<t11vke$1pk24$2@news.xmission.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=5099&group=comp.unix.shell#5099

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Terminal just hangs (Was: I can't cut fields from "fdisk -l")
Date: Fri, 18 Mar 2022 12:57:50 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <t11vke$1pk24$2@news.xmission.com>
References: <t11tbd$qh3$1@dont-email.me> <t11v5e$1kf$1@dont-email.me>
Injection-Date: Fri, 18 Mar 2022 12:57:50 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="1888324"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Fri, 18 Mar 2022 12:57 UTC

In article <t11v5e$1kf$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
....
>You are using the wrong tool; ignore cut, use awk.
>
> awk '{print $1,$5,$6}'

When I do that, my terminal just hangs and I have to reboot.

--
Faith doesn't give you the answers; it just stops you from asking the questions.

Re: Terminal just hangs (Was: I can't cut fields from "fdisk -l")

<t12035$kvs$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=5100&group=comp.unix.shell#5100

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Terminal just hangs (Was: I can't cut fields from "fdisk -l")
Date: Fri, 18 Mar 2022 14:05:40 +0100
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <t12035$kvs$1@dont-email.me>
References: <t11tbd$qh3$1@dont-email.me> <t11v5e$1kf$1@dont-email.me>
<t11vke$1pk24$2@news.xmission.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 18 Mar 2022 13:05:41 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f1aa0ff20907ebe22a9eba7bb989115b";
logging-data="21500"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/122zf1aSJcEKpxZE3D5K9"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:A5nwmhMfGq2eY2UEno2Eb712gEA=
In-Reply-To: <t11vke$1pk24$2@news.xmission.com>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Fri, 18 Mar 2022 13:05 UTC

On 18.03.2022 13:57, Kenny McCormack wrote:
> In article <t11v5e$1kf$1@dont-email.me>,
> Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
> ...
>> You are using the wrong tool; ignore cut, use awk.
>>
>> awk '{print $1,$5,$6}'
>
> When I do that, my terminal just hangs and I have to reboot.

What? - I suppose you know that this is just a replacement for the
cut process, and there's some pipeline commands (as given in the OP's
post) to prepend? sudo fdisk -l | ... | awk '{print $1,$5,$6}'
If that hangs on your system something on your system must be defect.

Janis

Re: Terminal just hangs (Was: I can't cut fields from "fdisk -l")

<t126pb$1ppm1$2@news.xmission.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=5101&group=comp.unix.shell#5101

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: Terminal just hangs (Was: I can't cut fields from "fdisk -l")
Date: Fri, 18 Mar 2022 14:59:55 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <t126pb$1ppm1$2@news.xmission.com>
References: <t11tbd$qh3$1@dont-email.me> <t11v5e$1kf$1@dont-email.me> <t11vke$1pk24$2@news.xmission.com> <t12035$kvs$1@dont-email.me>
Injection-Date: Fri, 18 Mar 2022 14:59:55 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="1894081"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Fri, 18 Mar 2022 14:59 UTC

In article <t12035$kvs$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
....
>sudo fdisk -l | ... | awk '{print $1,$5,$6}'

-bash: ...: command not found

Well, at least we are making progress. At least I don't have to reboot.

--
If you ask a Trumper who is to blame for the debacle of Jan 6, they will almost certainly say
something about Antifa/BLM/something/whatever. This shows just how screwed up they are; they can't
even get their narrative straight. What they *should* say is "Eugene Goodman". If not for him, the plot
would probably have succeeded, so he (Eugene) is clearly to blame for the failure.

Re: Terminal just hangs (Was: I can't cut fields from "fdisk -l")

<t12a4m$b9p$2@tncsrv09.home.tnetconsulting.net>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=5102&group=comp.unix.shell#5102

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!tncsrv06.tnetconsulting.net!tncsrv09.home.tnetconsulting.net!.POSTED.alpha.home.tnetconsulting.net!not-for-mail
From: gtay...@tnetconsulting.net (Grant Taylor)
Newsgroups: comp.unix.shell
Subject: Re: Terminal just hangs (Was: I can't cut fields from "fdisk -l")
Date: Fri, 18 Mar 2022 09:57:35 -0600
Organization: TNet Consulting
Message-ID: <t12a4m$b9p$2@tncsrv09.home.tnetconsulting.net>
References: <t11tbd$qh3$1@dont-email.me> <t11v5e$1kf$1@dont-email.me>
<t11vke$1pk24$2@news.xmission.com> <t12035$kvs$1@dont-email.me>
<t126pb$1ppm1$2@news.xmission.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 18 Mar 2022 15:57:10 -0000 (UTC)
Injection-Info: tncsrv09.home.tnetconsulting.net; posting-host="alpha.home.tnetconsulting.net:198.18.18.251";
logging-data="11577"; mail-complaints-to="newsmaster@tnetconsulting.net"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
In-Reply-To: <t126pb$1ppm1$2@news.xmission.com>
Content-Language: en-US
 by: Grant Taylor - Fri, 18 Mar 2022 15:57 UTC

On 3/18/22 8:59 AM, Kenny McCormack wrote:
> Well, at least we are making progress. At least I don't have to reboot.

sudo fdisk -l |tail -n 10|head -n 8|awk '{print $1,$5,$6}'

--
Grant. . . .
unix || die

Re: Terminal just hangs (Was: I can't cut fields from "fdisk -l")

<t130mc$sch$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=5106&group=comp.unix.shell#5106

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Terminal just hangs (Was: I can't cut fields from "fdisk -l")
Date: Fri, 18 Mar 2022 23:22:04 +0100
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <t130mc$sch$1@dont-email.me>
References: <t11tbd$qh3$1@dont-email.me> <t11v5e$1kf$1@dont-email.me>
<t11vke$1pk24$2@news.xmission.com> <t12035$kvs$1@dont-email.me>
<t126pb$1ppm1$2@news.xmission.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 18 Mar 2022 22:22:04 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f1aa0ff20907ebe22a9eba7bb989115b";
logging-data="29073"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+oMMOnh6M/IY5xBELtPm8I"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:LWjhTHZwvPh5WjvtZxJM5fBJjGY=
In-Reply-To: <t126pb$1ppm1$2@news.xmission.com>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Fri, 18 Mar 2022 22:22 UTC

On 18.03.2022 15:59, Kenny McCormack wrote:
> In article <t12035$kvs$1@dont-email.me>,
> Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
> ...
>> sudo fdisk -l | ... | awk '{print $1,$5,$6}'
>
> -bash: ...: command not found
>
> Well, at least we are making progress. At least I don't have to reboot.

Your replies to my posts here are pathologic in several ways.

Foremost you know enough about awk and Unix that there's no need at
all to play the fool in the first place.

Then you seem to deliberately play the stupid to not understand that
my "You are using the wrong tool; ignore cut, use awk." was meant as
a suggestion to replace the cut part by the posted awk part, the one
I posted.

Finally if you really would reboot when entering a command that waits
for standard input you're hopelessly lost.

Have you forgotten to take your medicine or why are you unnecessarily
in sociopathic mode again?

Janis

Re: I can't cut fields from "fdisk -l"

<t142pm$893$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=5116&group=comp.unix.shell#5116

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: way...@nospam.invalid (Wayne)
Newsgroups: comp.unix.shell
Subject: Re: I can't cut fields from "fdisk -l"
Date: Sat, 19 Mar 2022 04:04:05 -0400
Organization: A noiseless patient Spider
Lines: 70
Message-ID: <t142pm$893$1@dont-email.me>
References: <t11tbd$qh3$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 19 Mar 2022 08:04:06 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="98db1331eb6dc3bfbfb8df77bbf3eda9";
logging-data="8483"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18QTd9Y7V1diWWKf1PZRKBXBVR7IGWCFCc="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Cancel-Lock: sha1:7f59p/Bi1uHYqr9CdAT7uwtzBtA=
In-Reply-To: <t11tbd$qh3$1@dont-email.me>
Content-Language: en-US
 by: Wayne - Sat, 19 Mar 2022 08:04 UTC

On 3/18/2022 8:18 AM, Ottavio Caruso wrote:
> Hi,
>
>
> $ sudo fdisk -l
> Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
> Disk model: HITACHI HTS72505
> Units: sectors of 1 * 512 = 512 bytes
> Sector size (logical/physical): 512 bytes / 4096 bytes
> I/O size (minimum/optimal): 4096 bytes / 4096 bytes
> Disklabel type: gpt
> Disk identifier: 6EC2F34F-F0E0-44EB-AF31-94969532B3A5
>
> Device         Start       End   Sectors  Size Type
> /dev/sda1       2048   1023999   1021952  499M Windows recovery environment
> /dev/sda2    1024000   1226751    202752   99M EFI System
> /dev/sda3    1226752   1259519     32768   16M Microsoft reserved
> /dev/sda4    1259520 103657471 102397952 48.8G Microsoft basic data
> /dev/sda5  103657472 206057471 102400000 48.8G Linux filesystem
> /dev/sda6  223012864 877277183 654264320  312G Microsoft basic data
> /dev/sda7  206057472 223012863  16955392  8.1G Linux swap
> /dev/sda8  877277184 976773119  99495936 47.5G Linux filesystem
>
> Partition table entries are not in disk order.
>
>
>
>
> $ sudo fdisk -l |tail -n 10|head -n 8
> /dev/sda1       2048   1023999   1021952  499M Windows recovery environment
> /dev/sda2    1024000   1226751    202752   99M EFI System
> /dev/sda3    1226752   1259519     32768   16M Microsoft reserved
> /dev/sda4    1259520 103657471 102397952 48.8G Microsoft basic data
> /dev/sda5  103657472 206057471 102400000 48.8G Linux filesystem
> /dev/sda6  223012864 877277183 654264320  312G Microsoft basic data
> /dev/sda7  206057472 223012863  16955392  8.1G Linux swap
> /dev/sda8  877277184 976773119  99495936 47.5G Linux filesystem
>
>
> So far, so good.
>
>
> Now, I only want fields 1 (Device), 5 (size) and 6 (Type):
>
>
> $ sudo fdisk -l |tail -n 10|head -n 8|cut -f 1,5,6 -d" "
> /dev/sda1
> /dev/sda2 1024000
> /dev/sda3 1226752
> /dev/sda4 1259520 103657471
> /dev/sda5 102400000 48.8G
> /dev/sda6 654264320
> /dev/sda7  16955392
> /dev/sda8  99495936
>
>
> What am I doing wrong?
>

The awk solution is probably best, but here's another solution:

$ sudo fdisk -l |tail -n 10|head -n 8 |tr -s ' ' |cut -f 1,5,6 -d" "

The tr command there squeezes runs of spaces into a single space.

--
Wayne

1
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor