Am 14.06.2011 22:35, schrieb Valery Mitsyn: > On Tue, 14 Jun 2011, Chetan Tiwari wrote: > >> Greetings, >> >> I was having trouble using the cut command and wasn't sure if anyone >> else on >> this list faced a similar problem. Perhaps I am doing something wrong and >> any help will be much appreciated. >> >> I am using SL6 and the version of cut installed is "cut (GNU coreutils) >> 8.4". I have a text file with the following line: >> >> abcdefghijklmnopqrstuvwxyz >> >> When I execute the following statement: "cut -c1-3,24- test.txt", I >> get the >> correct output: abcxyz. When I run the same command, but with a >> --output-delimiter flag (i.e. cut -c1-3,24- test.txt >> --output-delimiter="|"), I get the exact same output as before: >> abcxyz. The >> delimiter (I - pipe symbol) is missing. > > What is LANG/LC_ALL enveronment in your shell? > If it is something with .UTF-8 try to set it without suffix. > LANG=C cut --output-delimiter="|" -c 1-3,24- test.txt > should do the trick. >
Try to use -b (bytes) instead of -c (characters). It works for me. The info page of cut states that it is equal to -c at the moment but that info is probably outdated. While LANG=C works in my tests, oddly enough the results with LANG=de_DE.utf8 do not depend on the number of bytes in the delimiter character or the input. >> >> When I run the exact same commands on a machine running Ubuntu with "cut >> (GNU coreutils) 7.4", I get the desired output: abc|xyz. The same problem >> occurs with larger data files that I was trying to manipulate as well. >> Version 8.7 in Gentoo also seems to be correct. Hope this helps, Florian Philipp
signature.asc
Description: OpenPGP digital signature
