Skip to main content
delete code tag
Source Link
Kusalananda
  • 356.1k
  • 42
  • 737
  • 1.1k

You can't directly print the ascii codes by using the printf "%c" $i like in C language.

You have to first convert the decimal value of i into its octal valueconvert the decimal value of i into its octal value and then you have to print it using using printfprintf and putting \ in front of their respective octal values.

eg. To print A, you have to convert the decimal 65 into octal, i.e. 101, and then you have to print that octal value as:

printf "\101\n" 

This will print A.

So you have to modify it to :

for i in `seq 32 127`; do printf \\$(printf "%o" $i);done; 

But by using awk you can directly print like in C language

awk 'BEGIN{for(i=32;i<=127;i++)printf "%c",i}';echo 

You can't directly print the ascii codes by using the printf "%c" $i like in C language.

You have to first convert the decimal value of i into its octal value and then you have to print it using using printf and putting \ in front of their respective octal values.

eg. To print A, you have to convert the decimal 65 into octal i.e 101 and then you have to print that octal value as:

printf "\101\n" 

This will print A.

So you have to modify it to :

for i in `seq 32 127`; do printf \\$(printf "%o" $i);done; 

But by using awk you can directly print like in C language

awk 'BEGIN{for(i=32;i<=127;i++)printf "%c",i}';echo 

You can't directly print the ascii codes by using the printf "%c" $i like in C.

You have to first convert the decimal value of i into its octal value and then you have to print it using using printf and putting \ in front of their respective octal values.

To print A, you have to convert the decimal 65 into octal, i.e. 101, and then you have to print that octal value as:

printf "\101\n" 

This will print A.

So you have to modify it to :

for i in `seq 32 127`; do printf \\$(printf "%o" $i);done; 

But by using awk you can directly print like in C language

awk 'BEGIN{for(i=32;i<=127;i++)printf "%c",i}';echo 

You can't directly print the ascii codes by using the printf "%c" $i like in C language.

You have to first convert the decimal value of i into its octal valueconvert the decimal value of i into its octal value and then you have to print it using using printf and putting \ in front of their respective octal values.

Egeg. To print A, you have to convert the decimal 65 into octal i.e 101 and then you have to print that octal value as:

printf "\101\n" 

This will print A.

So you have to modify it to :

for i in `seq 32 127`; do printf \\$(printf "%o" $i);done; 

But by using awk you can directly print like in C language

awk 'BEGIN{for(i=32;i<=127;i++)printf "%c",i}';echo 

You can't directly print the ascii codes by using the printf "%c" $i like in C language.

You have to first convert the decimal value of i into its octal value and then you have to print it using using printf and putting \ in front of their respective octal values.

Eg. To print A, you have to convert the decimal 65 into octal i.e 101 and then you have to print that octal value as:

printf "\101\n" 

This will print A.

So you have to modify it to :

for i in `seq 32 127`; do printf \\$(printf "%o" $i);done; 

But by using awk you can directly print like in C language

awk 'BEGIN{for(i=32;i<=127;i++)printf "%c",i}';echo 

You can't directly print the ascii codes by using the printf "%c" $i like in C language.

You have to first convert the decimal value of i into its octal value and then you have to print it using using printf and putting \ in front of their respective octal values.

eg. To print A, you have to convert the decimal 65 into octal i.e 101 and then you have to print that octal value as:

printf "\101\n" 

This will print A.

So you have to modify it to :

for i in `seq 32 127`; do printf \\$(printf "%o" $i);done; 

But by using awk you can directly print like in C language

awk 'BEGIN{for(i=32;i<=127;i++)printf "%c",i}';echo 
deleted 2 characters in body
Source Link
pradeepchhetri
  • 10.2k
  • 13
  • 54
  • 61

You can't directly print the ascii codes by using the printf "%c" $i like in C language.

You have to first convert the decimal value of i into its octal value and then you have to print it using using printf and putting \ in front of their respective octal values.

Eg. To print A, you have to convert the decimal 65 into octal i.e 101 and then you have to print that octal value as:

printf "%c\101\n""\101\n" 

This will print A.

So you have to modify it to :

for i in `seq 32 127`; do printf \\$(printf "%o" $i);done; 

But by using awk you can directly print like in C language

awk 'BEGIN{for(i=32;i<=127;i++)printf "%c",i}';echo 

You can't directly print the ascii codes by using the printf "%c" $i like in C language.

You have to first convert the decimal value of i into its octal value and then you have to print it using using printf and putting \ in front of their respective octal values.

Eg. To print A, you have to convert the decimal 65 into octal i.e 101 and then you have to print that octal value as:

printf "%c\101\n" 

This will print A.

So you have to modify it to :

for i in `seq 32 127`; do printf \\$(printf "%o" $i);done; 

But by using awk you can directly print like in C language

awk 'BEGIN{for(i=32;i<=127;i++)printf "%c",i}';echo 

You can't directly print the ascii codes by using the printf "%c" $i like in C language.

You have to first convert the decimal value of i into its octal value and then you have to print it using using printf and putting \ in front of their respective octal values.

Eg. To print A, you have to convert the decimal 65 into octal i.e 101 and then you have to print that octal value as:

printf "\101\n" 

This will print A.

So you have to modify it to :

for i in `seq 32 127`; do printf \\$(printf "%o" $i);done; 

But by using awk you can directly print like in C language

awk 'BEGIN{for(i=32;i<=127;i++)printf "%c",i}';echo 
added 99 characters in body
Source Link
pradeepchhetri
  • 10.2k
  • 13
  • 54
  • 61
Loading
Source Link
pradeepchhetri
  • 10.2k
  • 13
  • 54
  • 61
Loading