Sponsored Content
Top Forums Shell Programming and Scripting cat file_list | [script to print last some characters] Post 302347190 by mr_bold on Tuesday 25th of August 2009 05:44:39 AM
Old 08-25-2009
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
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print the characters in a word

Hi, How can I split the characters in a word? For Eg: If my input is: command my output should be: c o m m a n d Please help me in doing it so. (5 Replies)
Discussion started by: chella
5 Replies

2. Shell Programming and Scripting

print 10 characters in series

suppose fileA kanika123ABC 1222222222222222 raciat5678ty 1221123333331121 jessica78ulllo 2233243223333333 so output shud be print only first 10 characters in series and rest remain same kanika123A 1222222222222222 raciat5678 1221123333331121 jessica78u ... (1 Reply)
Discussion started by: cdfd123
1 Replies

3. UNIX for Dummies Questions & Answers

Difference between cat , cat > , cat >> and touch !!!

Hi Can anybody tell the difference between Difference between cat , cat > , cat >> and touch command in UNIX? Thanks (6 Replies)
Discussion started by: skyineyes
6 Replies

4. Shell Programming and Scripting

cat in the command line doesn't match cat in the script

Hello, So I sorted my file as I was supposed to: sort -n -r -k 2 -k 1 file1 | uniq > file2 and when I wrote > cat file2 in the command line, I got what I was expecting, but in the script itself ... sort -n -r -k 2 -k 1 averages | uniq > temp cat file2 It wrote a whole... (21 Replies)
Discussion started by: shira
21 Replies

5. Shell Programming and Scripting

Print the first four characters of hostname

Hey, I'm trying to print the first four characters of the hostname of a computer. I can get it from using: hostname -s | sed 's/...........$//'" but this is when I know how many characters are in the computer name. I dont understand why some like: hostname -s | sed '/..../p' wont... (7 Replies)
Discussion started by: yxian
7 Replies

6. Shell Programming and Scripting

Extra control characters being added when I create a file using cat command

Hi, I am using Cygwin.I created a new file and type into it using cat > newfile. When I open this using vi editor, it contains loads of extra control characters. Whats happening? (1 Reply)
Discussion started by: erora
1 Replies

7. Shell Programming and Scripting

Use awk to print first 6 characters

Hi, i want to use awk to print the first 6 characters of a variable awk -F"|" '$3>0 { print $3 }' z00.unl > z001.unl but $3= 7 digits and i just want to print the first 6 digits. eg 1005779 but i want to print only 100577 (3 Replies)
Discussion started by: dealerso
3 Replies

8. Shell Programming and Scripting

Print N characters in ksh

Hi, I have this header on a script: echo "*************************************" How can I print 1000 "*" characters without to put them on the echo command? Understand? THIS IS AN EXAMPLE WHAT I NEED: print "1000 *" Or is possible to print or echo "*" characters until they... (8 Replies)
Discussion started by: iga3725
8 Replies

9. UNIX for Advanced & Expert Users

cat / sed process weird characters

Hi everyone, I'm trying to write a shell script that process a log file. The log format is generally: (8 digit hex of unix time),(system ID),(state)\n My shell script gets the file from the web, saves it in a local text directory. I then want to change the hex to decimal, convert from unix time... (7 Replies)
Discussion started by: bencpeters
7 Replies

10. Shell Programming and Scripting

How to print the first 7 characters of each column

Hello all, I have a data like this: X:04252 X:05524 X:04176 X:05509 X:05524 X:04674- X:1662912 X:10181 X:16491 X:05506 X:05216- X:05488 X:46872 X:08471 X:04834 X:30170 The except result is like this: X:04252 X:05524 X:04176 X:05509 X:05524 X:04674 X:16629 X:10181... (3 Replies)
Discussion started by: yhkoo
3 Replies
MB_STRTOLOWER(3)							 1							  MB_STRTOLOWER(3)

mb_strtolower - Make a string lowercase

SYNOPSIS
string mb_strtolower (string $str, [string $encoding = mb_internal_encoding()]) DESCRIPTION
Returns $str with all alphabetic characters converted to lowercase. PARAMETERS
o $str - The string being lowercased. o $encoding -The $encoding parameter is the character encoding. If it is omitted, the internal character encoding value will be used. RETURN VALUES
$str with all alphabetic characters converted to lowercase. UNICODE
For more information about the Unicode properties, please see http://www.unicode.org/unicode/reports/tr21/. By contrast to strtolower(3), 'alphabetic' is determined by the Unicode character properties. Thus the behaviour of this function is not affected by locale settings and it can convert any characters that have 'alphabetic' property, such as A-umlaut (A). EXAMPLES
Example #1 mb_strtolower(3) example <?php $str = "Mary Had A Little Lamb and She LOVED It So"; $str = mb_strtolower($str); echo $str; // Prints mary had a little lamb and she loved it so ?> Example #2 mb_strtolower(3) example with non-Latin UTF-8 text <?php $str = "Txiotn a nE Baos unuvn yn, dpaokeCei unp vw0po kuvs"; $str = mb_strtolower($str, 'UTF-8'); echo $str; // Prints txiotn a nE Baos unuvn yn, dpaokeCei unp vw0po kuvs ?> SEE ALSO
mb_strtoupper(3), mb_convert_case(3), strtolower(3). PHP Documentation Group MB_STRTOLOWER(3)
All times are GMT -4. The time now is 08:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy