Sponsored Content
Full Discussion: search and replace symlinks
Top Forums UNIX for Advanced & Expert Users search and replace symlinks Post 87057 by Perderabo on Wednesday 19th of October 2005 03:06:47 PM
Old 10-19-2005
This is a little on the dangerous side to say the least. Run this script...it will produce a second script. Examine that second script carefully before you run it.
Code:
#! /usr/bin/ksh

function dodir
{
        typeset fname data savedir
        ls | while read fname ; do
                if [[ -L $fname ]] ; then
                        data=$(ls -l $fname)
                        data=${data##* }
                        data=$(echo "$data" | sed 's=myfoo=yourfoo=')
                        echo rm $1/$fname
                        echo ln -s $data $1/$fname
                elif [[ -d $fname ]] ; then
                        savedir=$(pwd)
                        cd $fname
                        dodir $savedir/$fname
                        cd $savedir
                fi
        done
        return
}

dodir $(pwd)
exit 0

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Nested Symlinks?

Please don't laugh or call me a fool... I'm trying to set up a script that will go through my Music File directory and generate a set of symbolic links in a directory called "What's New". Within that directory there will be a "30 Days", "3 Months", "6 Months" and "A Year" directories. Within... (0 Replies)
Discussion started by: deckard
0 Replies

2. Shell Programming and Scripting

Perl: Search for string on line then search and replace text

Hi All, I have a file that I need to be able to find a pattern match on a line, search that line for a text pattern, and replace that text. An example of 4 lines in my file is: 1. MatchText_randomNumberOfText moreData ReplaceMe moreData 2. MatchText_randomNumberOfText moreData moreData... (4 Replies)
Discussion started by: Crypto
4 Replies

3. UNIX for Dummies Questions & Answers

Symlinks

Given a filename, is it possible to know haow many symbolic links are pointing to it? How can I tell? (1 Reply)
Discussion started by: ct1977
1 Replies

4. Shell Programming and Scripting

awk - replace number of string length from search and replace for a serialized array

Hello, I really would appreciate some help with a bash script for some string manipulation on an SQL dump: I'd like to be able to rename "sites/WHATEVER/files" to "sites/SOMETHINGELSE/files" within the sql dump. This is quite easy with sed: sed -e... (1 Reply)
Discussion started by: otrotipo
1 Replies

5. Shell Programming and Scripting

perl search and replace - search in first line and replance in 2nd line

Dear All, i want to search particular string and want to replance next line value. following is the test file. search string is tmp,??? ,10:1 "???" may contain any 3 character it should remain the same and next line replace with ,10:50 tmp,123 --- if match tmp,??? then... (3 Replies)
Discussion started by: arvindng
3 Replies

6. Slackware

Context dependent symlinks

Ive got multiple PCs, sharing an NFS mounted home dir. For certain apps I would like to keep the config files host specific. Easy solution is to create symlinks to local folders for configs. Ideally I would still want the .config files to reside in the user home folder. Is it possible to... (2 Replies)
Discussion started by: agentrnge
2 Replies

7. Shell Programming and Scripting

Look for, backup and delete symlinks

Hi, My first post here: Was looking if someone can help enhancing my code. I am limited to sh or ash shell (android / busybox) I made a script to look for busybox symlinks, backup them and delete them I have these questions about the below code: - busybox tar do not has the options... (2 Replies)
Discussion started by: Phil3759
2 Replies

8. Shell Programming and Scripting

Find + Symlinks = me confused

So i have read the man pages a few time. Searched google but I am not quite sure i understand all the lingo. What i want to do is list all files on / except i dont want any symlinks (because if I am searching / I will find the "true" file...correct?) So there is the -P, -H, and '-type l'... (2 Replies)
Discussion started by: nitrobass24
2 Replies

9. Shell Programming and Scripting

Nested search in a file and replace the inner search

Hi Team, I am new to unix, please help me in this. I have a file named properties. The content of the file is : ##Mobile props east.url=https://qa.east.corp.com/prop/end west.url=https://qa.west.corp.com/prop/end south.url=https://qa.south.corp.com/prop/end... (2 Replies)
Discussion started by: tolearn
2 Replies

10. Shell Programming and Scripting

Rsync move with symlinks

Hi, I use rsync to move from source to target, but there are cases that I need to exclude: Suppose in my file system, I have a soft link ~/data -> /media/volgrp/data. Under data folder, there is a file hello.txt. After moving command "rsync --remove-source-files -aH --force ~/data/... (3 Replies)
Discussion started by: huangyingw
3 Replies
WM-ICONS-CONFIG(1)					      General Commands Manual						WM-ICONS-CONFIG(1)

NAME
wm-icons-config - show and set configuration for wm-icons SYNOPSIS
wm-icons-config [options] NAME [ICON_SET] ... DESCRIPTION
This show wm-icons package configuration, and the list of installed icon sets. It also is used to set aliases to icon-sets in system or user space. In the synopsis above, NAME is icon alias name, ICON_SET is icon set directory (for example: mini 16x16-default). If NAME already exists as an alias, it is not overwritten, unless the --force option is given. Explicit NAMEs override --defaults. Just the alias names are given for --which and --remove options. OPTIONS
Informational options: display info and exit --help Print a short usage message --version Show version number and exit --inst-dir Show wm-icons installed icon directory and exit --user-dir Show wm-icons user icon directory and exit --show-defaults Show default aliases and exit --show-aliases Show the aliases currently present. One of --global, --personal, --user-dir must be given --show-sets Show a list of installed icon sets Directory selection options: precisely one of these must be given --global Set up global (system-wide) links in the base dir --personal Set up personal links in ~/.wm-icons --user-dir=USER_DIR Set up links in USER_DIR Choice of links: at least one of these must be given --defaults Set up default aliases, as shown by --show-defaults Extra options --remove Remove the symlinks rather than creating them, return (0, 1) --which Show the icon set for the given alias(es), return (0, 1) --quiet Do not output results of alias manipulating to stdout --force Force overwriting of existing symlinks BUGS
None known. AUTHORS
Mikhael Goikhman <migo (at) cpan.org> and others (see file AUTHORS). This manual page was initially written by Manoj Srivastava <srivasta@debian.org>, for the Debian GNU/Linux system. 09-Apr-2006 WM-ICONS-CONFIG(1)
All times are GMT -4. The time now is 06:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy