Sort by

recency

|

50 Discussions

|

  • + 0 comments

    line="你好世界" # Chinese characters echo "${line:0:4}" Output: �

    this is where cut will work

  • + 1 comment

    I'm not sure why this isn't working. Test case 2 is failing for no apparent reason. This is the most elegant solution, thank you very much Zorse Unlimited

    while read X; do
        echo "${X:0:4}"
    done
    
  • + 0 comments

    cut -b 1-4

  • + 0 comments

    Simple Code

    while read lines; do
        echo $lines | cut -c 0-4
    done
    
  • + 1 comment

    why the fk does this not work? Test case 2 fails, for no reason. This IS the most elegant solution thank you very much.

    while read X; do
        echo "${X:0:4}"
    done