The UNIX and Linux Forums  

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
using sed to get rid of duplicated columns... fedora Shell Programming and Scripting 5 11-28-2008 10:45 AM
Row to Columns vskr72 UNIX for Dummies Questions & Answers 4 03-21-2007 09:53 AM
extracting from tar.bz2 Raom UNIX for Advanced & Expert Users 1 03-07-2006 10:33 AM
Extracting columns from different files for later merging kingkong UNIX for Dummies Questions & Answers 2 11-23-2005 03:21 AM
add columns with awk tonet Shell Programming and Scripting 4 06-21-2005 04:02 AM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 04-02-2008
praveenbvarrier praveenbvarrier is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 15
Need help in extracting columns

Hi ,

I have a file having around 8 columns spereated by space . Now that I need to extract columns from this. The problem is this functionality is needed in a script and the required columns are dynamic and can range from 2 columns to 8 columns at a time .

What I tried without luck is
If I could get the required column numbers in a variable in the below format
var_col="1\" \"\$2\" \"\$3"

awk -v awkvar=$var_col '{print $awkvar}'

here I expected to print the 1st,2nd and 3rd cols seprated by a space.But this did not work.


Can somebody help me out here please ?
 

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:47 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