|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
||||
|
||||
|
Code:
#! /bin/bash
while read path
do
lnNm=${path//\//#}
lnNm=${lnNm%#}
ln -s "$path" "/home/Document/Shortcut/$lnNm"
done < file |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Quote:
i try Quote:
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
|
||||
|
||||
|
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 | ||
|
![]() |
| Thread Tools | Search this Thread |
| 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 |
|
|