Skip to main content
deleted 49 characters in body
Source Link

bash, 6150 bytes

while b=${a%%?^H*}${a#*?^H};[[ "$b""$a" != "$a$a""${a/?^H/}" ];do a=${ba/?^H/};done

Sample:

a=$'Horse^H^H^H^H^HCow' 
while b=${a%%?^H*}${a#*?^H};[[ "$b""$a" != "$a$a""${a/?^H/}" ];do a=${ba/?^H/};done
echo $a
Cow

a="Be nice to this fool^H^H^H^Hgentleman, he's visiting from corporate HQ."
while b=${a%%?^H*}${a#*?^H};[[ "$b""$a" != "$a$a""${a/?^H/}" ];do a=${ba/?^H/};done
echo $a
Be nice to this gentleman, he's visiting from corporate HQ.

This could work with real (binaries) backspaces as well:

a=$'Be nice to this fool\b\b\b\bgentleman, he'\'$'s visiting from corporate HQ.'
echo $a.. but:
Be nice to this gentleman, he's visiting from corporate HQ... but:
printf %q\\n "$a"
$'Be nice to this fool\b\b\b\bgentleman, he\'s visiting from corporate HQ.'

while b=${a%%?$'\b'*}${a#*?$'\b'};[[ "$b""$a" != "$a$a""${a/?$'\b'/}" ];do a=${ba/?$'\b'/};done
printf %q\\n "$a"
Be\ nice\ to\ this\ gentleman\,\ he\'s\ visiting\ from\ corporate\ HQ.

bash, 61 bytes

while b=${a%%?^H*}${a#*?^H};[ "$b" != "$a$a" ];do a=${b};done

Sample:

a=$'Horse^H^H^H^H^HCow' 
while b=${a%%?^H*}${a#*?^H};[ "$b" != "$a$a" ];do a=${b};done
echo $a
Cow

a="Be nice to this fool^H^H^H^Hgentleman, he's visiting from corporate HQ."
while b=${a%%?^H*}${a#*?^H};[ "$b" != "$a$a" ];do a=${b};done
echo $a
Be nice to this gentleman, he's visiting from corporate HQ.

This could work with real (binaries) backspaces as well:

a=$'Be nice to this fool\b\b\b\bgentleman, he'\'$'s visiting from corporate HQ.'
echo $a.. but:
Be nice to this gentleman, he's visiting from corporate HQ... but:
printf %q\\n "$a"
$'Be nice to this fool\b\b\b\bgentleman, he\'s visiting from corporate HQ.'

while b=${a%%?$'\b'*}${a#*?$'\b'};[ "$b" != "$a$a" ];do a=${b};done
printf %q\\n "$a"
Be\ nice\ to\ this\ gentleman\,\ he\'s\ visiting\ from\ corporate\ HQ.

bash, 50 bytes

while [ "$a" != "${a/?^H/}" ];do a=${a/?^H/};done

Sample:

a=$'Horse^H^H^H^H^HCow'
while [ "$a" != "${a/?^H/}" ];do a=${a/?^H/};done
echo $a
Cow

a="Be nice to this fool^H^H^H^Hgentleman, he's visiting from corporate HQ."
while [ "$a" != "${a/?^H/}" ];do a=${a/?^H/};done
echo $a
Be nice to this gentleman, he's visiting from corporate HQ.

This could work with real (binaries) backspaces as well:

a=$'Be nice to this fool\b\b\b\bgentleman, he'\'$'s visiting from corporate HQ.'
echo $a.. but:
Be nice to this gentleman, he's visiting from corporate HQ... but:
printf %q\\n "$a"
$'Be nice to this fool\b\b\b\bgentleman, he\'s visiting from corporate HQ.'

while [ "$a" != "${a/?$'\b'/}" ];do a=${a/?$'\b'/};done
printf %q\\n "$a"
Be\ nice\ to\ this\ gentleman\,\ he\'s\ visiting\ from\ corporate\ HQ.
added 1 character in body
Source Link

bash, 61 bytes

while b=${a%%?^H*}${a#*?^H};[ "$b" != "$a$a" ];do a=${b};done

Sample:

a=$'Horse^H^H^H^H^HCow' 
while b=${a%%?^H*}${a#*?^H};[ "$b" != "$a$a" ];do a=${b};done
echo $a
Cow

a="Be nice to this fool^H^H^H^Hgentleman, he's visiting from corporate HQ."
while b=${a%%?^H*}${a#*?^H};[ "$b" != "$a$a" ];do a=${b};done
echo $a
Be nice to this gentleman, he's visiting from corporate HQ.

This could work with real (binaries) backspaces as well:

a=$'Be nice to this fool\b\b\b\bgentleman, he'\'$'s visiting from corporate HQ.'
echo $a.. but:
Be nice to this gentleman, he's visiting from corporate HQ... but:
printf %q\\n "$a"
$'Be nice to this fool\b\b\b\bgentleman, he\'s visiting from corporate HQ.'

while b=${a%%?$'\b'*}${a#*?$'\b'};[ "$b" != "$a$a" ];do a=${b};done
printf %q\\n "$a"
Be\ nice\ to\ this\ gentleman\,\ he\'s\ visiting\ from\ corporate\ HQ.

bash 61 bytes

while b=${a%%?^H*}${a#*?^H};[ "$b" != "$a$a" ];do a=${b};done

Sample:

a=$'Horse^H^H^H^H^HCow' 
while b=${a%%?^H*}${a#*?^H};[ "$b" != "$a$a" ];do a=${b};done
echo $a
Cow

a="Be nice to this fool^H^H^H^Hgentleman, he's visiting from corporate HQ."
while b=${a%%?^H*}${a#*?^H};[ "$b" != "$a$a" ];do a=${b};done
echo $a
Be nice to this gentleman, he's visiting from corporate HQ.

This could work with real (binaries) backspaces as well:

a=$'Be nice to this fool\b\b\b\bgentleman, he'\'$'s visiting from corporate HQ.'
echo $a.. but:
Be nice to this gentleman, he's visiting from corporate HQ... but:
printf %q\\n "$a"
$'Be nice to this fool\b\b\b\bgentleman, he\'s visiting from corporate HQ.'

while b=${a%%?$'\b'*}${a#*?$'\b'};[ "$b" != "$a$a" ];do a=${b};done
printf %q\\n "$a"
Be\ nice\ to\ this\ gentleman\,\ he\'s\ visiting\ from\ corporate\ HQ.

bash, 61 bytes

while b=${a%%?^H*}${a#*?^H};[ "$b" != "$a$a" ];do a=${b};done

Sample:

a=$'Horse^H^H^H^H^HCow' 
while b=${a%%?^H*}${a#*?^H};[ "$b" != "$a$a" ];do a=${b};done
echo $a
Cow

a="Be nice to this fool^H^H^H^Hgentleman, he's visiting from corporate HQ."
while b=${a%%?^H*}${a#*?^H};[ "$b" != "$a$a" ];do a=${b};done
echo $a
Be nice to this gentleman, he's visiting from corporate HQ.

This could work with real (binaries) backspaces as well:

a=$'Be nice to this fool\b\b\b\bgentleman, he'\'$'s visiting from corporate HQ.'
echo $a.. but:
Be nice to this gentleman, he's visiting from corporate HQ... but:
printf %q\\n "$a"
$'Be nice to this fool\b\b\b\bgentleman, he\'s visiting from corporate HQ.'

while b=${a%%?$'\b'*}${a#*?$'\b'};[ "$b" != "$a$a" ];do a=${b};done
printf %q\\n "$a"
Be\ nice\ to\ this\ gentleman\,\ he\'s\ visiting\ from\ corporate\ HQ.
added 518 characters in body
Source Link

bash 61 bytes

while b=${a%%?^H*}${a#*?^H};[ "$b" != "$a$a" ];do a=${b};done

Sample:

a=$'Horse^H^H^H^H^HCow' 
while b=${a%%?^H*}${a#*?^H};[ "$b" != "$a$a" ];do a=${b};done
echo $a
Cow

a="Be nice to this fool^H^H^H^Hgentleman, he's visiting from corporate HQ."
while b=${a%%?^H*}${a#*?^H};[ "$b" != "$a$a" ];do a=${b};done
echo $a
Be nice to this gentleman, he's visiting from corporate HQ.

This could work with real (binaries) backspaces as well:

a=$'Be nice to this fool\b\b\b\bgentleman, he'\'$'s visiting from corporate HQ.'
echo $a.. but:
Be nice to this gentleman, he's visiting from corporate HQ... but:
printf %q\\n "$a"
$'Be nice to this fool\b\b\b\bgentleman, he\'s visiting from corporate HQ.'

while b=${a%%?$'\b'*}${a#*?$'\b'};[ "$b" != "$a$a" ];do a=${b};done
printf %q\\n "$a"
Be\ nice\ to\ this\ gentleman\,\ he\'s\ visiting\ from\ corporate\ HQ.

bash 61 bytes

while b=${a%%?^H*}${a#*?^H};[ "$b" != "$a$a" ];do a=${b};done

Sample:

a=$'Horse^H^H^H^H^HCow' 
while b=${a%%?^H*}${a#*?^H};[ "$b" != "$a$a" ];do a=${b};done
echo $a
Cow

a="Be nice to this fool^H^H^H^Hgentleman, he's visiting from corporate HQ."
while b=${a%%?^H*}${a#*?^H};[ "$b" != "$a$a" ];do a=${b};done
echo $a
Be nice to this gentleman, he's visiting from corporate HQ.

bash 61 bytes

while b=${a%%?^H*}${a#*?^H};[ "$b" != "$a$a" ];do a=${b};done

Sample:

a=$'Horse^H^H^H^H^HCow' 
while b=${a%%?^H*}${a#*?^H};[ "$b" != "$a$a" ];do a=${b};done
echo $a
Cow

a="Be nice to this fool^H^H^H^Hgentleman, he's visiting from corporate HQ."
while b=${a%%?^H*}${a#*?^H};[ "$b" != "$a$a" ];do a=${b};done
echo $a
Be nice to this gentleman, he's visiting from corporate HQ.

This could work with real (binaries) backspaces as well:

a=$'Be nice to this fool\b\b\b\bgentleman, he'\'$'s visiting from corporate HQ.'
echo $a.. but:
Be nice to this gentleman, he's visiting from corporate HQ... but:
printf %q\\n "$a"
$'Be nice to this fool\b\b\b\bgentleman, he\'s visiting from corporate HQ.'

while b=${a%%?$'\b'*}${a#*?$'\b'};[ "$b" != "$a$a" ];do a=${b};done
printf %q\\n "$a"
Be\ nice\ to\ this\ gentleman\,\ he\'s\ visiting\ from\ corporate\ HQ.
Source Link
Loading