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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
whole word substitution in SED gikay01 Shell Programming and Scripting 7 07-16-2008 01:51 PM
Last word substitution capri_drm Linux 4 06-10-2008 03:19 AM
word substitution in unix capri_drm Linux 6 05-14-2008 11:36 AM
How to use sed substitution using a $variable for a line containing a word Sangal-Arun Shell Programming and Scripting 4 08-07-2007 04:09 PM
Can a shell script pull the first word (or nth word) off each line of a text file? tricky Shell Programming and Scripting 5 08-17-2006 03:29 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-15-2005
Registered User
 

Join Date: Aug 2005
Posts: 2
Stumble this Post!
word substitution in csh

I have data that looks something like this:

term1/term2/2005-12-01 13:20:30/term4

I need to make it look like this:

term1/term2/20051201132030/term4

I am using a csh script. I have tried to do it by first converting the date/time to the format in which I want it, and then replacing it using a tr command to replace the old date/time to the new one, but tr doesn't like strings of different lengths. Is there some other command I can use, or just an easier way of doing this altogether?

Thanks in advance...
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 09-15-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,002
Stumble this Post!
Code:
echo 'term1/term2/2005-12-01 13:20:30/term4' | nawk -F'[/]' -v OFS="/" '{ gsub(/[: -]/, "", $(NF-1)); print}'
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:36 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0