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
(Urgent):Creating flat file using sql script and sqlplus from UNIX Shell Script praka Shell Programming and Scripting 6 04-15-2009 07:09 AM
I want an urgent script Renjesh Shell Programming and Scripting 3 05-04-2008 11:49 PM
[urgent need help] about script bucci Shell Programming and Scripting 6 12-26-2006 01:21 AM
Script - Urgent Help troy86 Shell Programming and Scripting 4 06-01-2006 06:33 AM
FTP script urgent koduri0475 UNIX for Advanced & Expert Users 1 11-10-2005 11:02 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 05-06-2009
dsdev_123 dsdev_123 is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 26
urgent help awk script

Hi

I have a scenario where i have a file name as

abcd_To_hfgh.20090456778_1.dat

I will get the filename as parameter


and i need a string in between second _ and first . i.e i need hfgh in this case.

Please help me with the script. This may not be awk script even if it can be achivevd by a normal commands that sfine

thanks

Last edited by dsdev_123; 05-06-2009 at 01:00 PM..
  #2 (permalink)  
Old 05-06-2009
redhead's Avatar
redhead redhead is offline
Registered User
  
 

Join Date: Feb 2002
Location: Denmark
Posts: 68
echo "abcd_To_hfgh.20090456778_1.dat" | sed -e 's/_/ /g' -e 's/\./ /g' | awk '{print $3}'
  #3 (permalink)  
Old 05-06-2009
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131

Code:
echo 'abcd_To_hfgh.20090456778_1.dat' | nawk -F'[_.]' '{print $3}'

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 06:05 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