Sort by

recency

|

135 Discussions

|

  • + 0 comments
    1. Using cut Command: echo "$line" | cut -c3 Best For: Simple, single-character extraction. Limitation: Only handles one character at a time.
    2. Using Bash String Slicing Command: echo "${line:2:1}" Best For: Efficient, direct slicing of strings. Limitation: Fails on short or empty lines.
    3. Using awk Command: echo "Extra open brace or missing close brace0, 3, 1)}' Best For: More complex extraction with flexibility. Limitation: Overhead for simple tasks.
    4. Using while read Loop Command: while read line; do echo "${line:2:1}"; done Best For: Iterating over multiple lines. Limitation: Fails if lines are too short
  • + 0 comments

    Simplese cod e for bigners

    while read r
    do 
    echo "$r" | cut -c3
    done
    
  • + 0 comments

    read n for i in [1..toprint" | cut -c 3 done

  • + 0 comments
    #!/bin/bash
    
    N=1
    while [[ $N -ge 1 && $N -le 100 ]]; do
            let N++
            read n
            echo "$n" | cut -c 3
    done
    
  • + 0 comments

    echo "$(cut -c3)"