[ New messages · Members · Forum rules · Search · RSS ]
  • Page 1 of 1
  • 1
Forum moderator: shanky, Piyu, Resh  
Forum » Open System-Linux » Linux System questionare » Cut Command in Linux (Help needed for Cut Command in Linux)
Cut Command in Linux
Dipti VyasDate: Thursday, 2014-07-17, 10:04 AM | Message # 1
Group: Guests





From: Dipti Vyas
Posted At: Monday, July 14, 2014 8:07 PM
Posted To: UNIX
Conversation: Cut command
Subject: Cut command

Hello,

Has anyone worked on cut command in unix..

Please let me know.


Thanks and Regards,
Dipti
 
shankyDate: Thursday, 2014-07-17, 10:07 AM | Message # 2
Lieutenant
Group: Administrators
Messages: 46
Awards: 0
Reputation: 104
Status: Offline
cut is used for column filtering of the output.
Eg.
cut –d “:” –f1,3 filename
the above command will print 2nd and 3rd field of the file filename where the values are separated by the delimeter “:”.

File filename contains:

Shankar:kumar:Bhagat:Infosys
Raj:kumar:das:bipro

The output of above command will be:

Shankar Bhagat
Raj das

Regards
Shankar


s.k.bhagat
 
shankyDate: Thursday, 2014-07-17, 10:10 AM | Message # 3
Lieutenant
Group: Administrators
Messages: 46
Awards: 0
Reputation: 104
Status: Offline
On behalf of requester:

Yeah ..thnaks for your quick response..

However, I observed some column fields were extracted in unixbook for which output is not shown ..

If the cut definition  is applied on the existing tablecolumn fields, the output obtained is not correct ..

Regards,

Dipti

-----------------------------------------------------------------------------------------------------

One small  correction here:

The above command will print 1st and 3rdfield of the  file filename where the  values are separated by the
delimiter.. ":”

I have never seen using p option with cut command

Cut –d “:” –f 1,3p FILENAME

However, I think without system handy with me…. It will also be okie to use p here…

Will not make any  difference..

Regards,

Dipti Vyas


s.k.bhagat
 
shankyDate: Thursday, 2014-07-17, 12:38 PM | Message # 4
Lieutenant
Group: Administrators
Messages: 46
Awards: 0
Reputation: 104
Status: Offline
I have also not used p option in cut commad. Where did you get this command?:
Quote
Cut –d “:” –f 1,3p FILENAME

 
I dont see any confusion here. // cut -d ":" -f1,3 file // will print first and third fieldfrom the lines in a file where the words are seperated by ":".
You can use any delimeter. If you dont specify a delimeter or seperator, tab is used by default.
 
You can use spacebar also as delimeter.
Is there any requirement for ur script, give details, Will try to resolve.
Thanks.


s.k.bhagat
 
Forum » Open System-Linux » Linux System questionare » Cut Command in Linux (Help needed for Cut Command in Linux)
  • Page 1 of 1
  • 1
Search: