Readin document & creating path | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Readin document & creating path

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-31-2013
gogok_bg gogok_bg is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 21 March 2013, 10:24 AM EDT
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
Readin document & creating path

Need a way to read a file in who every line is a path to a directory and make shortcut to that directory on a specific place.

Example:
line in the document

Code:
/media/gogo/6651-FEAB/Desktop/ 
/media/gogo/6651-FEAB/Desktop/alex/ 
/media/gogo/6651-FEAB/linux/ 
/media/gogo/6651-FEAB/eks/HDD.Regenerator.2011-RES/INFOS/

and i need a way to crate a shortcut in a folder to every line ( path ) from the code above.
to
Code:
/media/gogo/6651-FEAB/Desktop

need a shortcut in
Code:
/home/Document/Shortcut/

and for name of the shortcut need the path it self ( /media/gogo/6651-FEAB/Desktop ), it should look like this -- > for
Code:
/media/gogo/6651-FEAB/Desktop

-->
Code:
/home/Document/Shortcut/#media#gogo#6651-FEAB#Desktop

( i know "/" cant be used for a name of directory & file ).
Same for the second line:
for
Code:
/media/gogo/6651-FEAB/Desktop/alex

-->
Code:
/home/Document/Shortcut/#media#gogo#6651-FEAB#Desktop#alex

and soo on until the file end. Someone up for the task

ps: the name may not be the name of the path it self actually it could be a whatever, like for the first line 1, second 2 and soo on...

Last edited by gogok_bg; 01-31-2013 at 04:32 AM..
Sponsored Links
    #2  
Old 01-31-2013
balajesuri's Avatar
balajesuri balajesuri is offline Forum Advisor  
#! /bin/bash
 
Join Date: Apr 2009
Last Activity: 1 September 2014, 11:34 AM EDT
Location: India
Posts: 1,822
Thanks: 24
Thanked 523 Times in 502 Posts

Code:
#! /bin/bash

while read path
do
    lnNm=${path//\//#}
    lnNm=${lnNm%#}
    ln -s "$path" "/home/Document/Shortcut/$lnNm"
done < file

Sponsored Links
    #3  
Old 02-01-2013
gogok_bg gogok_bg is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 21 March 2013, 10:24 AM EDT
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by balajesuri View Post
Code:
#! /bin/bash

while read path
do
    lnNm=${path//\//#}
    lnNm=${lnNm%#}
    ln -s "$path" "/home/Document/Shortcut/$lnNm"
done < file

Cant get it work. The document is in /home/gogo/Document/gara1

i try
Quote:
Originally Posted by balajesuri View Post
Code:
#!/bin/bash
path="/home/gogo/Documents/gara1"
while read path

while read path
do
    lnNm=${path//\//#}
    lnNm=${lnNm%#}
    ln -s "$path" "/home/gogo/Document/Shortcut/$lnNm"
done < "/home/gogo/Documents/gara1"
#done

ln: failed to create symbolic link `/home/gogo/Document/Shortcut/#media#gogo#6651-FEAB#Desktop': No such file or directory
ln: failed to create symbolic link `/home/gogo/Document/Shortcut/#media#gogo#6651-FEAB': No such file or directory

I think the problem is that directory must be made before it can get linked but not sure :/

Last edited by gogok_bg; 02-01-2013 at 02:52 AM..
    #4  
Old 02-01-2013
balajesuri's Avatar
balajesuri balajesuri is offline Forum Advisor  
#! /bin/bash
 
Join Date: Apr 2009
Last Activity: 1 September 2014, 11:34 AM EDT
Location: India
Posts: 1,822
Thanks: 24
Thanked 523 Times in 502 Posts
Try this:

Code:
#! /bin/bash
while read var
do
    lnNm=${var//\//#}
    lnNm=${lnNm%#}
    ln -s "$var" "/home/Document/Shortcut/$lnNm" 
done < /home/gogo/Document/gara1

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Creating word document (.doc) with attachment in unix solaris ajay547 Shell Programming and Scripting 5 03-13-2012 01:01 PM
File creating in another path.. application unable to locate Pradeep Garine Shell Programming and Scripting 1 04-30-2011 08:50 AM
Creating tar without path (directory structure) included in it royalibrahim Shell Programming and Scripting 9 10-13-2010 01:53 PM
creating & sending formatted (with bolds & colors) CSV infaWorld Shell Programming and Scripting 2 08-26-2008 03:24 PM
Creating alias for directory path jasjot31 UNIX for Dummies Questions & Answers 3 09-25-2006 08:04 AM



All times are GMT -4. The time now is 07:24 PM.