The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
current CPU usage, memory usage, disk I/O oid(snmp) S_venkatesh SUN Solaris 2 12-13-2008 06:19 AM
cpu%/mem% usage, scripting, dzen2: howto learn bash the hard way broli Gentoo 14 08-17-2008 06:40 PM
passing variable from bash to perl from bash script arsidh Shell Programming and Scripting 10 06-04-2008 12:25 PM
Basic bash 'for loop' usage Orange Stripes Shell Programming and Scripting 2 12-18-2007 08:58 PM
Monitor CPU usage and Memory Usage Gajanad Bihani High Level Programming 2 03-09-2005 07:35 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-17-2008
tsurko tsurko is offline
Registered User
  
 

Join Date: Jun 2007
Location: Sofia, Bulgaria
Posts: 35
cut usage in bash

Hello,
Could you put some light on this:
Code:
> echo "ref_categorie=test" | cut -c1-15-
test
> echo "ref_categorie=test" | cut -c1-14-
=test
echo "ref_categorie=test" | cut -c15-
test
echo "ref_categorie=test" | cut -c15 
t
>
It's executed on AIX if that matters. The man page is not very verbose. What I've figured out myself is that cut -c removes chars from string (which is stated in manpage actually ). I've found a few examples via Google. So after -c is the chars position I suppose. Also it looks like that without the trailing dash cut just prints the char at this position.
Here is what I don't understand:
1) "ref_categorie=" is 14 chars, why -c14- leaves also the '='?
2) What's the difference between -c15- and -c1-15- ? They do the same in my case, but maybe there is something that I'm missing.
Thank you very much for your help!
  #2 (permalink)  
Old 11-17-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink

Three basic formats of the -c option in the cut command

-c15 will cut character position 15
-c1-15 will cut character positions 1 thru 15
-c15- will cut from character position 15 to the end

I would think that your first two examples would be giving some kind of syntax error as they are not standard or correct.

Lastly, you can specify more character positions than simply one range. See the following
-c1-5,10-11,21-
cut positions 1 through 5, 10 through 11, and from 21 to the end

Last edited by joeyg; 11-17-2008 at 10:04 AM..
  #3 (permalink)  
Old 11-17-2008
tsurko tsurko is offline
Registered User
  
 

Join Date: Jun 2007
Location: Sofia, Bulgaria
Posts: 35
It does make sense now. Thank you very much, joeyg.
Closed Thread

Bookmarks

Tags
bash cut

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:43 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0