LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Editing a file using awk (https://www.linuxquestions.org/questions/linux-newbie-8/editing-a-file-using-awk-804945/)

riteshanand40 04-29-2010 06:40 AM

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

colucix 04-29-2010 07:01 AM

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



All times are GMT -5. The time now is 01:34 AM.