From unknown Sun Jun 22 22:40:36 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#7076 <7076@debbugs.gnu.org> To: bug#7076 <7076@debbugs.gnu.org> Subject: Status: Command required Reply-To: bug#7076 <7076@debbugs.gnu.org> Date: Mon, 23 Jun 2025 05:40:36 +0000 retitle 7076 Command required reassign 7076 coreutils submitter 7076 Imran Shoaib severity 7076 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 20 11:47:46 2010 Received: (at submit) by debbugs.gnu.org; 20 Sep 2010 15:47:46 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oxian-0005Pt-Cc for submit@debbugs.gnu.org; Mon, 20 Sep 2010 11:47:46 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OxdMg-0002ZW-GZ for submit@debbugs.gnu.org; Mon, 20 Sep 2010 06:12:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OxdP4-00070u-Q2 for submit@debbugs.gnu.org; Mon, 20 Sep 2010 06:15:20 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,HTML_MESSAGE, T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:37677) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OxdP4-00070q-NG for submit@debbugs.gnu.org; Mon, 20 Sep 2010 06:15:18 -0400 Received: from [140.186.70.92] (port=51859 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OxdP3-0002Ef-Cu for bug-coreutils@gnu.org; Mon, 20 Sep 2010 06:15:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OxdP2-00070Z-4h for bug-coreutils@gnu.org; Mon, 20 Sep 2010 06:15:17 -0400 Received: from mail1.ubl.com.pk ([202.125.129.126]:50785) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OxdP0-0006zV-MA for bug-coreutils@gnu.org; Mon, 20 Sep 2010 06:15:16 -0400 Received: from ([192.168.150.1]) by mail1.ubl.com.pk with ESMTP with TLS id B51HCH1.31548773; Mon, 20 Sep 2010 15:13:10 +0500 Received: from ISBEMAIL.pk.ubl.int (10.64.100.251) by KCI-CASHT02.pk.ubl.int (10.1.140.58) with Microsoft SMTP Server id 8.2.176.0; Mon, 20 Sep 2010 15:14:34 +0500 Subject: Command required MIME-Version: 1.0 Content-Class: urn:content-classes:message X-MimeOLE: Produced By Microsoft Exchange V6.5 Date: Mon, 20 Sep 2010 15:10:48 +0500 Message-ID: <9048E830B0AB9F4CA3C228F58A0D61910435508D@ISBEMAIL.pk.ubl.int> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Command required thread-index: ActYrBjDPinLT+FFRQ6dxPss53XpGw== X-Priority: 1 Priority: Urgent Importance: high From: Imran Shoaib To: Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01CB58AC.17D1C287" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Mon, 20 Sep 2010 11:47:44 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.3 (-----) ------_=_NextPart_001_01CB58AC.17D1C287 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable How can we extract few characters from second or third line of a text=0D=0A= file using cut command of Linux OS?=0D=0A=0D=0A =0D=0A=0D=0AFor example: to= get 7-10 characters from 3rd line of a text file is=0D=0Arequired, what ca= n be the command?=0D=0A=0D=0A =0D=0A=0D=0A =0D=0A=0D=0ARegards,=0D=0A=0D=0A= =0D=0A=0D=0AImran=0D=0A=0D=0A =0D=0A=0D=0A=0D=0A=0D=0A=0D=0A=0D=0A=0D=0A= =0D=0A=0D=0AThis E-mail and any files transmitted with it are confidential = and=0Aintended solely for the use of the individual or entity to which=0Ath= ey are addressed=2E If you have received this E-mail in error=0Aplease noti= fy the sender or mailto:e-help@ubl=2Ecom=2Epk=2E This E-mail=0Amessage and = attachment, if any, has been scanned for all known=0Aviruses, however we ad= vice the recipient to check this E-mail and=0Aany attachments for the prese= nce of viruses, UBL accepts no=0Aliability for any damage caused by any vir= us transmitted by this=0AE-mail=2E Further, e-mail transmission is not guar= anteed as=0Aerror-free=2E UBL therefore does not accept liability for any e= rrors=0Aor omissions in the contents of any messages that arise out of=0Ae-= mail transmission=2E ------_=_NextPart_001_01CB58AC.17D1C287 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable =0D=0A=0D=0A=0D=0A=0D=0A=0D=0A=0D=0A=0D=0A=0D=0A=0D=0A=0D=0A=0D=0A=0D=0A=0D=0A

How can we extract few=0D=0Acharacters from second or third= line of a text file using cut=0D=0Acommand of Linux OS?

=0D= =0A=0D=0A

<= span=0D=0Astyle=3D'font-size:11=2E0pt;color:navy;font-weight:normal'>&= nbsp;

=0D=0A=0D=0A

For example: to get 7-10=0D=0Acharacters from= 3rd line of a text file is required, what can be the=0D=0Acomma= nd?

=0D=0A=0D=0A

 

=0D= =0A=0D=0A

<= span=0D=0Astyle=3D'font-size:11=2E0pt;color:navy;font-weight:normal'>&= nbsp;

=0D=0A=0D=0A

Regards,

=0D= =0A=0D=0A

<= span=0D=0Astyle=3D'font-size:11=2E0pt;color:navy;font-weight:normal'>&= nbsp;

=0D=0A=0D=0A

Imran

=0D=0A= =0D=0A

 

=0D=0A=0D=0A= =0D=0A=0D=0A=0D=0A=0D=0A=0D=0A=0D=0A=0D=0A=0D=0A=0D=0A=0D=0A= =0D=0AThis E-mail and any files transmitted with it are confidential and in= tended solely for the use of the individual or entity to which they are add= ressed=2E If you have received this E-mail in error please notify the sende= r or mailto:e-help@ubl=2Ecom=2Epk=2E This E-mail message and attachment, if= any, has been scanned for all known viruses, however we advice the recipie= nt to check this E-mail and any attachments for the presence of viruses, UB= L accepts no liability for any damage caused by any virus transmitted by th= is E-mail=2E Further, e-mail transmission is not guaranteed as error-free= =2E UBL therefore does not accept liability for any errors or omissions in = the contents of any messages that arise out of e-mail transmission=2E ------_=_NextPart_001_01CB58AC.17D1C287-- From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 20 17:18:51 2010 Received: (at 7076-done) by debbugs.gnu.org; 20 Sep 2010 21:18:51 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OxnlC-0000Kb-Mc for submit@debbugs.gnu.org; Mon, 20 Sep 2010 17:18:51 -0400 Received: from joseki.proulx.com ([216.17.153.58]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OxnlA-0000KV-Qe for 7076-done@debbugs.gnu.org; Mon, 20 Sep 2010 17:18:49 -0400 Received: from hysteria.proulx.com (hysteria.proulx.com [192.168.230.119]) by joseki.proulx.com (Postfix) with ESMTP id CC35A21361; Mon, 20 Sep 2010 15:21:18 -0600 (MDT) Received: by hysteria.proulx.com (Postfix, from userid 1000) id C77892DCE7; Mon, 20 Sep 2010 15:21:18 -0600 (MDT) Date: Mon, 20 Sep 2010 15:21:18 -0600 From: Bob Proulx To: Imran Shoaib Subject: Re: bug#7076: Command required Message-ID: <20100920212118.GA6814@hysteria.proulx.com> References: <9048E830B0AB9F4CA3C228F58A0D61910435508D@ISBEMAIL.pk.ubl.int> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9048E830B0AB9F4CA3C228F58A0D61910435508D@ISBEMAIL.pk.ubl.int> User-Agent: Mutt/1.5.20 (2009-06-14) X-Spam-Score: -2.4 (--) X-Debbugs-Envelope-To: 7076-done Cc: 7076-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.4 (--) Imran Shoaib wrote: > How can we extract few characters from second or third line of a text > file using cut command of Linux OS? In the future please send discussion questions concerning the coreutils to the coreutils mailing list instead of the bug-coreutils. The bug-coreutils mailing list is for bug reports only and every email message opens up a bug in the bug tracking system. I am closing this bug report but discussion may continue. Thanks. A good place for general help questions is help-gnu-utils@gnu.org. > For example: to get 7-10 characters from 3rd line of a text file is > required, what can be the command? I would use sed for this. Don't print by default (-n) and then print the 3rd line. $ printf "1234567890\n1234567890\n1234567890\n" | sed -n 3p If you want specific characters then you can delete the unwanted ones. This is a contrived example: $ printf "1234567890\n1234567890\n1234567890\n" | sed -n '3{s/^..\(..\).*/\1/;p;}' Or you can chain commands together. Print only the third line to a command that pulls apart fields. $ printf "11 12 13\n21 22 23\n31 32 33\n" | awk 'NR==3{print$2}' 32 $ printf "11 12 13\n21 22 23\n31 32 33\n" | awk 'NR==3{print $2, $3}' 32 33 > This E-mail and any files transmitted with it are confidential and > intended solely for the use of the individual or entity to which > they are addressed. If you have received this E-mail in error In the future please do not include such useless and annoying disclaimers in your email. The terms are incompatible with a free software mailing list. If you cannot avoid this then please use one of the many free email providers on the network. Bob From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 22 02:50:25 2010 Received: (at 7076) by debbugs.gnu.org; 22 Sep 2010 06:50:25 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OyJ9t-0006Np-DI for submit@debbugs.gnu.org; Wed, 22 Sep 2010 02:50:25 -0400 Received: from mail1.ubl.com.pk ([202.125.129.126]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OyJ9p-0006Nj-EP for 7076@debbugs.gnu.org; Wed, 22 Sep 2010 02:50:23 -0400 Received: from ([192.168.150.1]) by mail1.ubl.com.pk with ESMTP with TLS id B51HCH1.31673517; Wed, 22 Sep 2010 11:51:17 +0500 Received: from ISBEMAIL.pk.ubl.int (10.64.100.252) by KCI-CASHT02.pk.ubl.int (10.1.140.58) with Microsoft SMTP Server id 8.2.176.0; Wed, 22 Sep 2010 11:52:48 +0500 Subject: RE: bug#7076: closed (Re: bug#7076: Command required) Date: Wed, 22 Sep 2010 10:33:49 +0500 MIME-Version: 1.0 Message-ID: <9048E830B0AB9F4CA3C228F58A0D6191043B85F6@ISBEMAIL.pk.ubl.int> X-MS-Has-Attach: yes Content-Class: urn:content-classes:message X-MimeOLE: Produced By Microsoft Exchange V6.5 X-MS-TNEF-Correlator: Thread-Topic: bug#7076: closed (Re: bug#7076: Command required) thread-index: ActZDInrn5zGO+Q2Sau5YtCPiG6ElABCnqmg X-Priority: 1 Priority: Urgent Importance: high From: Imran Shoaib To: <7076@debbugs.gnu.org>, Content-Type: multipart/mixed; boundary="----_=_NextPart_001_01CB5A17.BDA56ABF" X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 7076 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.1 (---) ------_=_NextPart_001_01CB5A17.BDA56ABF Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable =0D=0AThanks for the details, but what if information is to be read from fi= le=0D=0Aand not from command line pattern?=0D=0A=0D=0AFor example from atta= ched file we need to read characters 15 to 22 of=0D=0Aline 3 and use these = characters only as input in any other file=2E Please=0D=0Aadvise=2E=0D=0A= =0D=0A=0D=0AImran=0D=0A-----Original Message-----=0D=0AFrom: GNU bug Tracki= ng System [mailto:help-debbugs@gnu=2Eorg] =0D=0ASent: Tuesday, September 21= , 2010 2:19 AM=0D=0ATo: Imran Shoaib=0D=0ASubject: bug#7076: closed (Re: bu= g#7076: Command required)=0D=0A=0D=0AYour bug report=0D=0A=0D=0A#7076: Comm= and required=0D=0A=0D=0Awhich was filed against the coreutils package, has = been closed=2E=0D=0A=0D=0AThe explanation is attached below, along with you= r original report=2E=0D=0AIf you require more details, please reply to 7076= @debbugs=2Egnu=2Eorg=2E=0D=0A=0D=0A-- =0D=0A7076: http://debbugs=2Egnu=2Eor= g/cgi/bugreport=2Ecgi?bug=3D7076=0D=0AGNU Bug Tracking System=0D=0AContact = help-debbugs@gnu=2Eorg with problems=0D=0A=0D=0A=0D=0A=0D=0A=0D=0A=0D=0A=0D= =0A=0D=0AThis E-mail and any files transmitted with it are confidential and= =0Aintended solely for the use of the individual or entity to which=0Athey = are addressed=2E If you have received this E-mail in error=0Aplease notify = the sender or mailto:e-help@ubl=2Ecom=2Epk=2E This E-mail=0Amessage and att= achment, if any, has been scanned for all known=0Aviruses, however we advic= e the recipient to check this E-mail and=0Aany attachments for the presence= of viruses, UBL accepts no=0Aliability for any damage caused by any virus = transmitted by this=0AE-mail=2E Further, e-mail transmission is not guarant= eed as=0Aerror-free=2E UBL therefore does not accept liability for any erro= rs=0Aor omissions in the contents of any messages that arise out of=0Ae-mai= l transmission=2E ------_=_NextPart_001_01CB5A17.BDA56ABF Content-Type: text/plain; name="sample.txt" Content-Transfer-Encoding: base64 Content-Description: sample.txt Content-Disposition: attachment; filename="sample.txt" QUJDIERFRiBHSFUgSEpLIExLTQ0KR0ZIVCBKSEpHUlREIEhHSEpGSkYgVFRIREhERA0KU0ZMSiBT REZMU0pGIFNERkxTREpGIERGU0RGSkwgSktERlNERg0KRkxTREZKIFNERkRTREZKIERGRVIwVE9S IERTU0RKTEZKIEFTTEoNCkZGSFNEIEtTREZIU0QgT1NERlNMIERGSlNERkxIDQoNCg== ------_=_NextPart_001_01CB5A17.BDA56ABF-- From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 22 16:34:04 2010 Received: (at 7076) by debbugs.gnu.org; 22 Sep 2010 20:34:04 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OyW0y-0004HL-Kd for submit@debbugs.gnu.org; Wed, 22 Sep 2010 16:34:04 -0400 Received: from joseki.proulx.com ([216.17.153.58]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OyW0w-0004Gz-4R for 7076@debbugs.gnu.org; Wed, 22 Sep 2010 16:34:02 -0400 Received: from hysteria.proulx.com (hysteria.proulx.com [192.168.230.119]) by joseki.proulx.com (Postfix) with ESMTP id 9A69D21361; Wed, 22 Sep 2010 14:36:37 -0600 (MDT) Received: by hysteria.proulx.com (Postfix, from userid 1000) id 969292DCE7; Wed, 22 Sep 2010 14:36:37 -0600 (MDT) Date: Wed, 22 Sep 2010 14:36:37 -0600 From: Bob Proulx To: Imran Shoaib Subject: Re: bug#7076: closed (Re: bug#7076: Command required) Message-ID: <20100922203637.GA14988@hysteria.proulx.com> Mail-Followup-To: Imran Shoaib , 7076@debbugs.gnu.org, help-gnu-utils@gnu.org References: <9048E830B0AB9F4CA3C228F58A0D61910435508D@ISBEMAIL.pk.ubl.int> <9048E830B0AB9F4CA3C228F58A0D6191043B85F6@ISBEMAIL.pk.ubl.int> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9048E830B0AB9F4CA3C228F58A0D6191043B85F6@ISBEMAIL.pk.ubl.int> User-Agent: Mutt/1.5.20 (2009-06-14) X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: 7076 Cc: 7076@debbugs.gnu.org, help-gnu-utils@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.4 (--) Imran Shoaib wrote: > Thanks for the details, but what if information is to be read from file > and not from command line pattern? Then read the data from the file instead of the command line. > For example from attached file we need to read characters 15 to 22 of > line 3 and use these characters only as input in any other file. Please > advise. For that specific case using 'awk' is easiest for me. In awk the FNR variable is "the input record number in the current input file" or the current line number. Use it to only take action on the 3rd line of the file. FNR == 3 Then the substr(s,i,n) function next seems easiest. The substr() function returns the substr from 's' starting at index position 'i' and containing at most 'n' characters. Since $0 is the current line string we use that. substr($0,15,8); # return characters 15 to 22 of the line. Then print the result. Putting that all together yieds this: $ printf "one\ntwo\nabcdefghijklmnopqrstuvwxyz\n" | awk 'FNR==3{print substr($0,15,8);}' opqrstuv The command line example was how I developed the case. Because then everything is contained in the example and it can be shared. You were asking how to read a file. Most utilities read files in the argument list. So to read a file simply place the file in the argument list. $ awk 'NR==3{print substr($0,15,8);}' /tmp/sample.txt DFLSDJF > This E-mail and any files transmitted with it are confidential and Please do not include such useless and annoying disclaimers in your email. The terms are incompatible with a free software mailing list. If you cannot avoid this because your company adds it for you then please use one of the many free email providers on the network when conversing on mailing lists. Those accounts are free and freely available and do not include such legal text. I am unlikely to respond to subsequent messages if they still include such legal text in the future. Bob From unknown Sun Jun 22 22:40:36 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 21 Oct 2010 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator