更新时间:2023-08-28 15:27:22
您可以像这样使用sed:
You can use sed like this:
s =''1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4''
p =''1 2 3 4''
echo"
s=''1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4''
p=''1 2 3 4''
echo "
s" | sed"s/
s"|sed "s/
p \ s */& \ n/g"
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
p\s*/&\n/g"
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
您可以使用无限while循环,并使用输入文件并遍历每一行,以便将此逻辑用于多行.
实时演示
http://ideone.com/P59OCJ [
You can use infinite while loop and use the input file and iterate through each line to use this logic for murtiple lines.
Live Demo
http://ideone.com/P59OCJ[^]