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
URL call from SHELL script chengwei Shell Programming and Scripting 37 04-15-2009 10:52 PM
Call shell script from php not run ? raccsdl Shell Programming and Scripting 2 11-19-2007 08:21 AM
how can i call a shell script from pl/sql rajesh.P Shell Programming and Scripting 3 09-17-2007 12:09 AM
how can a call shell script from pl/sql rajesh.P UNIX for Dummies Questions & Answers 0 09-14-2007 03:42 AM
How to call a shell script from awk ? Amruta Pitkar Shell Programming and Scripting 1 04-20-2007 05:35 AM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 06-08-2009
attonbitusira attonbitusira is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 3
How to call last 14 characters with grep/sed in shell script.

Hi. This is my first post on the forums.

I am trying to write a script that will parse a folder of files "oneverylongfilenamexyz.pdf" and create a .dat file named "oneverylongfilenamexyz.dat" with the first line of each .dat file saying variable="xyz" where xyz is the last 14 characters of $i before the extension.

My syntax is very poor but I think the logic should be something like

# first loop to make dat files
for i in `ls -R dat_tmp/ | grep .pdf`
touch $i.dat
# second loop to fill dat files
for i in `ls -l | grep .dat`
echo 'variable=`sed[last 14 characters] $i`' > $i.dat


Any help is much appreciated. Thank you.

Last edited by attonbitusira; 06-08-2009 at 05:12 PM.. Reason: made some progress
 

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 07:15 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