LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-29-2010, 07:40 AM   #1
riteshanand40
LQ Newbie
 
Registered: Dec 2007
Posts: 14

Rep: Reputation: 0
Editing a file using awk


Hi,

I have a list of millions of filename in form of say "drau3DDFEA5E01205841DC1B277A".
I need it convert it into
usr/local/data/d/dr/dra/drau/drau3DDFEA5E01205841DC1B277A

I believe that can be achieved by awk or sed.
I am very new to these. Can someone help plz.

Regards,
Ritesh
 
Old 04-29-2010, 08:01 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
No need for awk here. The shell manages substring extraction easily:
Code:
#!/bin/bash
filename=drau3DDFEA5E01205841DC1B277A
for i in {1..4}
do
  filepath=$filepath/${filename:0:$i}
done
filepath=usr/local/data$filepath/$filename
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Editing text using AWK gregarion Programming 12 01-12-2010 12:04 AM
read-only file system error when editing a config file smallfrowne Linux - Newbie 5 02-19-2008 07:06 PM
editing a very large HTML file (or, extracting URLs from a file) Chriswaterguy Linux - Software 3 11-27-2007 07:07 PM
awk: fatal:cannot open file for reading (no such file or Directory) in Linux sangati vishwanath Linux - Software 4 07-06-2005 01:59 AM
editing a file using awk pantera Programming 1 05-14-2004 09:40 AM


All times are GMT -5. The time now is 10:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration