คู่มือ
-p pattern
The file is split whenever an input line matches pattern,
which is interpreted as an extended regular expression. The
matching line will be the first line of the next output file.
This option is incompatible with the -b and -l options.
รหัส
seq -w 1 1 10 | gsed ':a;N;$!ba;s/\n//g' | split -p '060'
ซึ่งจะทำให้ลำดับจาก 1 ถึง 10 เอาบรรทัดว่างจะมี megastring แล้วแยกที่เป็นสองไฟล์ไม่ประสบความสำเร็จให้060split: invalid option -- 'p'
คำสั่งseq -w 1 1 10 | awk -F'060' '{print "field1: "$1 "\nfield2: 060"$2}'ในการแสดงความคิดเห็นให้
field1: 01 field2: 060 field1: 02 field2: 060 field1: 03 field2: 060 field1: 04 field2: 060 field1: 05 field2: 060 field1: 06 field2: 060 field1: 07 field2: 060 field1: 060 09 field2: 060 field1: 10 field2: 060
ซึ่งไม่ใช่สิ่งที่ฉันต้องการ ฉันต้องการแยกไฟล์ที่เครื่องหมาย060เป็นสองไฟล์ คุณสามารถรวม060ถึงไฟล์ใดไฟล์หนึ่ง
คุณสามารถใช้ flag -p ใน BSD Split ใน OSX ได้อย่างไร
man splitเกี่ยวกับ BSD ในขณะที่จริงของฉันsplitเกี่ยวกับ GNU
seqและgsedคำสั่งในขณะที่ทำหน้าที่แทนawkสำหรับsplit? การส่งออกคำสั่งต่อไปนี้เป็นสองสายหนึ่งfield1: 0102030405และอื่น ๆ field2: 0607080910คือ คำสั่งคือ:seq -w 1 1 10 | gsed ':a;N;$!ba;s/\n//g' | awk -F'060' '{print "field1: "$1 "\nfield2: 060"$2}'
split'แสดงให้เห็นว่าคุณอาจไม่ได้เรียกร้องที่ถูกต้อง อะไรwhich splitกลับมา?