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 > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk sed cut? to rearrange random number of fields into 3 fields axo959 Shell Programming and Scripting 4 04-29-2009 05:18 AM
need help with awk in printing the fields in a file sais Shell Programming and Scripting 4 10-07-2008 06:48 AM
AWK - printing certain fields when field order changes in data file eric4 Shell Programming and Scripting 3 04-15-2008 07:48 PM
Sorting Files / Combing Fields / Printing ccfc1986 Shell Programming and Scripting 12 12-03-2007 02:38 PM
printing select fields in awk maverix Shell Programming and Scripting 5 06-22-2007 10:25 AM

Reply
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 08-24-2009
Jahn Jahn is offline
Registered User
  
 

Join Date: May 2009
Posts: 9
Printing First Three Fields

Hello,

I have several files in the following format:

1*2,3,4,5

And I wish to only print the first three fields, including the special characters '*' and ','. I have used awk to print fields before, but I do not know how to do it to include the delimiters, and how you can do it with delimiters of different types. Any help would be greatly appreciated!

Thank you,

-Jahn
  #2 (permalink)  
Old 08-24-2009
methyl methyl is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 1,175
Code:
echo "1*2,3,4,5"|cut -d, -f1-3

1*2,3,4
Code:
File called "myfile.txt".

1*2,3,4,5
alpha,b*ta,*gamma,delta*,omega


cut -d, -f1-3 myfile.txt

1*2,3,4
alpha,b*ta,*gamma
Reply

Bookmarks

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 08:04 AM.


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