Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- test1,test2,test3
- test4,test5
- test6,test7,test8,test9,test10
- test11,test12,test13,test14
- test1,test2;test3
- test4,test5
- test6,test7;test8;test9;test10
- test11,test12;test13;test14
- $ sed 's/,/n/g; s/n/,/; s/n/;/g' input
- test1,test2;test3
- test4,test5
- test6,test7;test8;test9;test10
- test11,test12;test13;test14
- $ sed -e 's/,/;/g' -e 's/;/,/1' infile
- test1,test2;test3
- test4,test5
- test6,test7;test8;test9;test10
- test11,test12;test13;test14
- sed 's/,/;/2g' infile
- awk '{gsub(",", ";"); sub(";", ","); print}' file.txt
- % cat file.txt
- test1,test2,test3
- test4,test5
- test6,test7,test8,test9,test10
- test11,test12,test13,test14
- % awk '{gsub(",", ";"); sub(";", ","); print}' file.txt
- test1,test2;test3
- test4,test5
- test6,test7;test8;test9;test10
- test11,test12;test13;test14
- txr -e '(each ((line (get-lines)))
- (set [line (rest (where (op eql #,) line))]
- (repeat ";"))
- (put-line line))' < input
- $ txr
- This is the TXR Lisp interactive listener of TXR 148.
- Use the :quit command or type Ctrl-D on empty line to exit.
- 1> (take 3 (repeat ";"))
- (#; #; #;)
- 2> (let ((a "a,b,c"))
- a)
- "a,b,c"
- 3> (let ((a "a,b,c"))
- [a '(1 3)])
- ",,"
- 4> (let ((a "a,b,c"))
- (where (op eql #,) a))
- (1 3)
- 5> (let ((a "a,b,c"))
- (set [a '(1 3)] (repeat ";"))
- a)
- "a;b;c"
- 6> (let ((a "a,b,c"))
- (set [a (where (op eql #,) a)] (repeat ";"))
- a)
- "a;b;c"
- 7> (let ((a "a,b,c"))
- (set [a (rest (where (op eql #,) a))] (repeat ";"))
- a)
- "a,b;c"
- 8> (let ((a ""))
- (set [a (rest (where (op eql #,) a))] (repeat ";"))
- a)
- ** replace-str: "" of type lit is not a modifiable string
- ** during evaluation of form (sys:dwim-set a #:g0145 #:g0144)
- ** ... an expansion at expr-8:2 of (sys:dwim-set (#:g0146) #:g0145
- #:g0144)
- ** which is located at expr-8:2
- 9> (let ((a (copy "")))
- (set [a (rest (where (op eql #,) a))] (repeat ";"))
- a)
- ""
- 10> (let ((a "a"))
- (set [a (rest (where (op eql #,) a))] (repeat ";"))
- a)
- "a"
- 11> (let ((a "a,b"))
- (set [a (rest (where (op eql #,) a))] (repeat ";"))
- a)
- "a,b"
Add Comment
Please, Sign In to add comment