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
Print the first four characters of hostname yxian Shell Programming and Scripting 7 06-15-2009 05:21 PM
print 10 characters in series cdfd123 Shell Programming and Scripting 1 04-28-2008 01:18 AM
Print the characters in a word chella Shell Programming and Scripting 5 10-17-2007 10:06 AM
How to ignore characters and print only number using unix? cdfd123 UNIX for Dummies Questions & Answers 5 08-03-2007 04:47 AM
AIX cannot print thai characters ivanwee AIX 0 10-18-2006 04:13 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-25-2009
mr_bold mr_bold is offline
Registered User
  
 

Join Date: Jan 2007
Location: UB, Mongolia
Posts: 32
cat file_list | [script to print last some characters]

Hello guys,

I have a list of files. For example:

Code:
/disk1/mediator_home/tmp/ntest/TSFILE00.8256.GGG1-U.0908250009.unp.20090824P8.is
/disk1/mediator_home/tmp/ntest/TSFILE00.8257.GGG1-U.0908250013.unp.20090825P1.is
/disk1/mediator_home/tmp/ntest/TSFILE00.8257.GGG1-U.0908250013.unp.20090824P8.ic
/disk1/mediator_home/tmp/ntest/TSFILE00.8256.GGG1-U.0908250009.unp.20061116P1.is
/disk1/mediator_home/tmp/ntest/TSFILE00.8257.GGG1-U.0908250013.unp.20090825P1.ic
/disk1/mediator_home/tmp/ntest/TSFILE00.8256.GGG1-U.0908250009.unp.20321116P1.is
/disk1/mediator_home/tmp/ntest/TSFILE00.8257.GGG1-U.0908250013.unp.20090824P8.is
/disk1/mediator_home/tmp/ntest/TSFILE00.8257.GGG1-U.0908250013.unp.20061116P1.is
/disk1/mediator_home/tmp/ntest/TSFILE01.2009.08.23.00181910.unp.20090823P1.ic
/disk1/mediator_home/tmp/ntest/TSFILE01.2009.08.23.00111909.unp.20090823P1.ic
/disk1/mediator_home/tmp/ntest/TSFILE01.2009.08.23.00111909.unp.20090822P8.ic
/disk1/mediator_home/tmp/ntest/TSFILE00.8256.GGG1-U.0908250009.unp.20090825P1.is
/disk1/mediator_home/tmp/ntest/TSFILE00.8254.GGG1-U.0908250002.unp.20090824P8.is
/disk1/mediator_home/tmp/ntest/TSFILE01.2009.08.23.00051908.unp.20090822P8.ic
/disk1/mediator_home/tmp/ntest/TSFILE01.2009.08.23.00051908.unp.20090823P1.ic
/disk1/mediator_home/tmp/ntest/TSFILE00.8255.GGG1-U.0908250005.unp.20090824P8.is
I need to get list of unique characters from the last, like this:
substring (s, length(s) - 13, 10)

For example: above output is:

Code:
20061116P1
20090822P8
20090823P1
20090824P8
20090825P1
20321116P1
Please help,

Thanks in advance
  #2 (permalink)  
Old 08-25-2009
chipcmc chipcmc is offline
Registered User
  
 

Join Date: Aug 2009
Location: spain
Posts: 93
Code:
awk -F"." '{ if (NF>0) print $(NF - 1)  }' file | sort -u
Bits Awarded / Charged to chipcmc for this Post
Date User Comment Amount
08-25-2009 mr_bold Thanks this works 50,000
  #3 (permalink)  
Old 08-25-2009
kd09714 kd09714 is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 14
try this also...

awk -F"/" '{ print $6 }' test_file | sed 's/-/./g' | awk -F"." '{ print $7 }' | sort |uniq



20061116P1
20090822P8
20090823P1
20090824P8
20090825P1
20321116P1
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:46 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