We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Linux Shell
- Text Processing
- Cut #1
- Discussions
Cut #1
Cut #1
Sort by
recency
|
125 Discussions
|
Please Login in order to post a comment
while read N do echo "$N" | cut -c 3 done
while read word do echo $word | cut -c 3 done
The Test Case 2 seems to be broken. The third character in the line is a dash while the expected result seems to be an empty line? Look:
C.B - Cantonment Board/Cantonment C.M.C – City Municipal Council C.T – Census Town E.O – Estate Office G.P - Gram Panchayat I.N.A – Industrial Notified Area I.T.S - Industrial Township M – Municipality M.B – Municipal Board M.C – Municipal Committee
Expected Output B M T O P N T B C
"It doesn't seem necessary to use the while statement since STDIN is already assigned. You can just type:
cut -c 3
I didn't wanted to use the cut -c3 approach so I used the following approach using array and I getting my testcase 2 failed. Can anybody help me as my code is printing "-" while testcase2's o/p is showing " " space as an o/p
!/bin/bash
arraystring=()
for ((i=1; i<=100; i++)); do
read -p "Enter INPUT")
if [ -z "$INPUT" ]; then break fi
done
for element in "${arraystring[@]}"; do
done