Created
January 17, 2018 07:42
-
-
Save Loveforkeeps/e1a460f0019e19d1c127a86ec1a8753f to your computer and use it in GitHub Desktop.
按指定行分割文件,并返回割裂的子文件路径。如: bash split.sh /Users/King/Desktop/zonefile/833.txt 100
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Author: ErDog | |
# 为了协调Mac上readlink -f无法使用,与脚本功能无关 | |
TARGET_FILE=$0 | |
cd `dirname $TARGET_FILE` | |
TARGET_FILE=`basename $TARGET_FILE` | |
while [ -L "TARGET_FILE" ] | |
do | |
TARGET_FILE=`readlink TARGET_FILE` | |
cd `dirname $TARGET_FILE` | |
TARGET_FILE=`basename $TARGET_FILE` | |
echo $TARGET_FILE | |
done | |
split -l $2 $1 $1_ | |
ls $1_* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment