Hot answers tagged ascii
6
For hysterical historical reasons, od prints two-byte words¹ by default.
The number 020061 (octal) corresponds to the two-byte sequence 1␣ (␣ is a space character). Why? It's clearer if you use hexadecimal: 0o20061 = 0x2031, and ␣ is 0x20 (32) in ASCII and 1 is 0x31 (49). Notice that the lower-order bits (0x31) correspond to the first character and the ...
4
grep is the standard tool for searching for a pattern inside of files. It has an option for searching recursively, which means if it finds a directory, it goes inside and searches in everything in there.
The command would simply be grep -r shirt /path/to/girl/
I also like to add two options that skip files that I know I'm not interested in: ...
3
This is the hexundump script from my personal collection:
#!/usr/bin/env perl
$^W = 1;
$c = undef;
while (<>) {
tr/0-9A-Fa-f//cd;
if (defined $c) { warn "Consuming $c"; $_ = $c . $_; $c = undef; }
if (length($_) & 1) { s/(.)$//; $c = $1; }
print pack "H*", $_;
}
if (!eof) { die "$!"; }
if (defined $c) { warn "Odd number of ...
3
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 ...
2
Beside OCR-Software, which was my first idea too, I think of libaa1 (ascii-art) and related programs. There is even a program to watch TV in ascii-art, ttv, so there will be an image transforming program, I'm pretty sure.
And I remember a program in the ImageMagick package, where you can take a photograph of a flipchart, and it performs ocr on it. ...
2
Interesting question. After browsing the man page, I found that -o prints octal output (od == octal dump), the c you appended only prints the associated characters as well. You get the same numbers with -o alone.
Looking at the output it appears that od is reading data two bytes at a time. Take the first two characters for instance:
CHAR - OCTAL - BINARY
1 ...
2
Try doing this in a shell :
To test on STDOUT :
column -t file.txt
To modify the file :
column -t file.txt > new_file.txt && mv new_file.txt file.txt
As you can see, that's all you need. It saves you a lot of time playing with complicated printf tricks.
2
You could use aha (also packaged in some Linux distributions), to convert the ANSI colouring sequences to HTML:
#! /bin/sh -
sendmail -t -oi << EOF
To: myaddy@domain.com
Subject: Weekly Disk Report
MIME-Version: 1.0
Content-Type: text/html; charset="us-ascii"
Content-Disposition: inline
$(discus | aha)
EOF
2
As stated by Shawn, using grep -r might be enough for your needs.
Otherwise a combination of find and grep can do the trick:
find . -exec grep -H text '{}' ';'
This allows to refine the search using specific find predicates.
(And -H option is there so that filenames are printed along with the matched content.)
1
GNU banner
figlet
toilet (tutorial)
As usual, you can read their man pages with the commands man banner, etc.
You might find these scripts useful: reverse the output horizontally, pad the output
1
xxd(1) can do this:
$ cat test.txt
Test.
$ xxd -b test.txt
0000000: 01010100 01100101 01110011 01110100 00101110 00001010 Test..
From this forum post.
1
Simulate a byte train:
echo 41 42 43 44 |
Change spaces into newlines so the while/read can easily parse them on by one
tr ' ' '\n' |
Parse byte by byte
while read hex; do
Convert hex to ascii:
printf \\x$hex
until end of input
done
If the files to parse are seriously big, you probably don't want to use bash because it is slow. PERL for ...
Only top voted, non community-wiki answers of a minimum length are eligible

