如何在Linux中的重复文件修改过程中排除带有符号链接的文件?

问题描述 投票:0回答:1

我想更改一些 SVG 文件的颜色代码。通常,我使用以下 bash 脚本:

#!/bin/bash

find -name "*.svg" -o -name "*.SVG" | while read i;
do 
  echo "This $i file will be updated"
  fname=$( basename "$i")
  fdir=$( dirname "$i")
  sed -i -e 's/<old-color>/<newcolor>/g' "$i" #grey
   
done

问题是,当我在符号链接文件上运行此脚本时,该文件会更改为正常的单独文件。

我的想法是排除所有符号链接文件,以便仅修改原始文件。但我不知道该怎么做。

linux bash svg symlink
1个回答
0
投票

好的,我得到了答案,只需添加

-type f
即可仅搜索常规文件

#!/bin/bash

find -type f -name "*.svg" -o -name "*.SVG" | while read i;
do 
  echo "This $i file will be updated"
  fname=$( basename "$i")
  fdir=$( dirname "$i")
  sed -i -e 's/<old-color>/<new-color>/g' "$i" #grey
   
done

来源如何查找不包括符号链接的文件?

© www.soinside.com 2019 - 2024. All rights reserved.