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
Passing the values to the secondary script when it invoked by primary script venu_eie UNIX for Advanced & Expert Users 2 07-03-2008 07:10 AM
Passing the values to the secondary script when it invoked by primary script venu_eie Shell Programming and Scripting 1 07-03-2008 06:16 AM
create a shell script that calls another script and and an awk script magikminox Shell Programming and Scripting 0 06-26-2008 02:50 AM
help me in sending parameters from sqlplus script to unix shell script Hara Shell Programming and Scripting 2 01-29-2008 03:31 PM
Shell Script: want to insert values in database when update script runs ring Shell Programming and Scripting 1 10-25-2007 03:06 AM

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

Join Date: Jun 2008
Posts: 28
awk script help

i have a file which looks like below

001259 HCART TLD 0 215 - 1 569953856 FULL
001405 HCART TLD 0 2 - 3 444650118 FULL/MPX
001473 HCART TLD 0 11 - 1 477960976 FULL/MPX
001484 HCART TLD 0 10 - 1 601812747 FULL/MPX
001498 HCART TLD 0 182 - 3 418481688 FULL/MPX
001500 HCART TLD 0 188 - 1 418912608 FULL/MPX



I want script output to show first col with colon delimited in a row and delete all other columns for example output should be like

001259:001405:001473:001484:001498:001500
  #2 (permalink)  
Old 11-24-2008
chatwizrd chatwizrd is offline
Banned
  
 

Join Date: Nov 2008
Posts: 67
cat file.txt | awk '{printf $1":"}' | sed 's/:$//'
  #3 (permalink)  
Old 11-24-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,212
Try this:

Code:
awk '{s=s?s":"$1:$1}END{print s}' file
  #4 (permalink)  
Old 11-24-2008
shehzad_m shehzad_m is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 28
Quote:
Originally Posted by Franklin52 View Post
Try this:

Code:
awk '{s=s?s":"$1:$1}END{print s}' file
I am getting an

awk: syntax error near line 1
awk: illegal statement near line 1
  #5 (permalink)  
Old 11-24-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,212
Quote:
Originally Posted by shehzad_m View Post
I am getting an

awk: syntax error near line 1
awk: illegal statement near line 1
Use nawk or /usr/xpg4/bin/awk on Solaris.
  #6 (permalink)  
Old 11-24-2008
shehzad_m shehzad_m is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 28
Thanks .
Sponsored Links
Closed Thread

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:17 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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