Hi, I have a requirement to replace 5 characters from position 8 for a each line with spaces in shell script.
Input:
001ABCD00001XYZ
097XYZU00034NYU
457GFDS08654YGTRequired Output:
001ABCD XYZ
097XYZU NYU
457GFDS YGTCould you someone please help me with the command to be used in UNIX.
Appreciate your help.
One way is to use the unix cut command to save the strings you want and glue them back together: #!/bin/ksh while read myline do var1=$(echo "$myline"|cut -c1-7) var2=$(echo "$myline"|cut -c13-) echo "${var1} ${var2}" done < dfile1.txt
@nails, with ksh, you can use substring. var1=${line:0:7} var2=${line:12:}
This works. Thank You.
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |