Hi, there
Can anybody tell me how can I read an ascii file character by character
using Korn shell or AWK.
any help welcom
Hi, there
Can anybody tell me how can I read an ascii file character by character
using Korn shell or AWK.
any help welcom
Hi Farouk,
You can separate each character in a file by using awk or nawk as follows
nawk '{ for(char=1;char<length($0);char++) \
print substring($0,char,char+1)}' inputfile
Atul Bhingarde
Hi Farouk,
Yes you can do that as follows.
nawk -F"|" '{ for(i=1;i<NF; i++) \
printf("%s,",substring($i,index($i,"=")+1,length($0)))}' inputfile
You will have to add a if statement to add carrieage return after last field
instead of a ",",
Hope it satisfies
Regards
Atul
Hi Farouk,
Yes you can do that as follows.
nawk -F"|" '{ for(i=1;i<NF; i++) \
printf("%s,",substring($i,index($i,"=")+1,length($0)))}' inputfile
You will have to add a if statement to add carrieage return after last field
instead of a ",",
Hope it satisfies
Regards
Atul
Hi Farouk,
Mostly some line in your file is longer than the awk capacity
Alternatively you can use fold command to wrap the file ( or lines ?? )
you can see the excat syntaxt of fole using man.
Basically fold folds each line into many lines with maximum length specified
I remember fold has syntax like "fold -c40"
fold -c50 input_file | nawk `{ ...... }`
Get back to me if you have any further questions on this matter.
Atul
1. the difference between binary file and ASCII file
hello,
if I have a unix shell script with permission ---x--x--x,
how can a unix shell detect that it is not an execuable binary
application and gives an error message "permission denied"?
Thanks,
Peter
2. CERN httpd -password protection setup
3. Converting an ASCII file to a Binary File
4. 4.1.3 client of 2.3 NIS+ problems
5. Can tex files be converted to ASCII files
6. Which book do you recommend to a Solaris new user?
7. appending binary file to ASCII file
8. diald brings up unwanted connection
9. Is there a difference between an "AIX" ASCII file and a "DOS" ASCII file
10. ascii file being recognized as Computer Graphics Metafile
11. vi: How to type S and ^Q in ascii file?
12. How can I format an ASCII file before printing
13. ascii file xfer with minicom