linux - separating file contents located between two characters into separate files -


i have file.txt various numbers separated brackets:

[133,406,789] [126,234,645]  

i'd parse numbers within brackets separate files:

file1.txt:     [133,406,789] file2.txt:     [126,234,645] ... ... file50.txt: [174,874,99,21,34] 

i have tried use command:

cat file.txt | sed s/[/\\n/g 

this get:

sed: -e expression #1, char 8: unterminated `s' command 

if can guarantee there spaces between square brackets , else then

awk '{n=split($0, tmp, /[[:space:]]+/); (i=1; i<=n; i++) print tmp[i] > "file_" fno++;}' 

will it. otherwise, need make regex little more clever. alternatively can @ 'csplit' shell command.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -