Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

6 votes
2 answers
523 views
How to make Perl half/full width-insensitive regular expressions?
In Perl, `/a/i` matches both A and a, so I don't have to write `/A|a/`. What is the easy way to write `/4|4/` ? Yes, I'm talking about ``` lang-sh $ unicode 4 4|grep U+ U+FF14 FULLWIDTH DIGIT FOUR U+0034 DIGIT FOUR ``` Must I repeat each line, ``` if (/大茅埔段32(7|8|9).地/ || /大茅埔段32(7|8|9).地/) {...} ``...
In Perl, /a/i matches both A and a, so I don't have to write /A|a/. What is the easy way to write /4|4/ ? Yes, I'm talking about
lang-sh
$ unicode 4 4|grep U+
U+FF14 FULLWIDTH DIGIT FOUR
U+0034 DIGIT FOUR
Must I repeat each line,
if (/大茅埔段32(7|8|9).地/ ||
        /大茅埔段32(7|8|9).地/)     {...}
or is there a better way? It's not that many characters, https://en.wikipedia.org/wiki/Halfwidth_and_Fullwidth_Forms_(Unicode_block) By the way, how to make
$ echo A|perl -pwle 's/a/x/i'
match? (Both A's are wide.)
Dan Jacobson (560 rep)
Feb 26, 2025, 02:16 AM • Last activity: Mar 1, 2025, 01:46 PM
9 votes
3 answers
4342 views
How to convert escape sequences to text while preserving display format?
I have a text file that contains (ANSI ?) escape sequences: [![raw file][1]][1] When I `cat` the file I get formatted output: [![formatted output][2]][2] How do I save / pipe the output of the text file to a new file so that the control codes are removed but the formatting is preserved? In other wor...
I have a text file that contains (ANSI ?) escape sequences: raw file When I cat the file I get formatted output: formatted output How do I save / pipe the output of the text file to a new file so that the control codes are removed but the formatting is preserved? In other words, I want to convert / export the contents of the file to a new file while retaining the intended display format (e.g. like one would get when using less -r ). I need an automated way to do this so that the output can be logged and sent as an email notification. Here is the base64 output of the file in the above screenshots (use base64 -d to decode it): G1tIG1syShtbMTsxSA0KG1s0OzRIICAgICAgICAgICAgICAgICAgICAgICAgICBDT05GSURFTlRJ QUwgSU5GT1JNQVRJT04bW0sbWzU7NEgbW0sbWzY7NEgbW0sbWzc7NEhUaGlzIHdvcmsgY29udGFp bnMgdmFsdWFibGUsIGNvbmZpZGVudGlhbCwgYW5kIHByb3ByaWV0YXJ5IGluZm9ybWF0aW9uLhtb SxtbODs0SERpc2Nsb3N1cmUsIHVzZSwgb3IgcmVwcm9kdWN0aW9uIGlzIGdvdmVybmVkIGJ5IHlv dXIgTGljZW5zZSBBZ3JlZW1lbnQuG1tLG1sxMDs0SBtbSxtbMTE7NEhUaGlzIHVucHVibGlzaGVk IHdvcmsgaXMgcHJvdGVjdGVkIGJ5IHRoZSBsYXdzIG9mIHRoZSBVbml0ZWQgU3RhdGVzIGFuZBtb SxtbMTI7NEhvdGhlciBDb3VudHJpZXMuICBUaGUgd29yayB3YXMgY3JlYXRlZCBpbiAxOTg4IGFu ZCByZXZpc2VkIGluIDE5OTQuICAbW0sbWzEzOzRISWYgcHVibGljYXRpb24gb2NjdXJzLCB0aGUg Zm9sbG93aW5nIG5vdGljZSBzaGFsbCBhcHBseTobW0sbWzE0OzRIG1tLG1sxNTs0SBtbSxtbMTY7 NEggICBDb3B5cmlnaHQgMTk4OCwxOTk0LiBBbGwgcmlnaHRzIHJlc2VydmVkLhtbSxtbMTc7NEgb W0sbWzE4OzRIG1tLG1sxOTs0SFRoaXMgQ29weXJpZ2h0IG5vdGljZSBhbmQgb3RoZXIgY29weXJp Z2h0IG5vdGljZXMgaW5jbHVkZWQgaW4gdGhlIG1hY2hpbmUbW0sbWzIwOzRIcmVhZGFibGUgY29w aWVzIG11c3QgYmUgcmVwcm9kdWNlZCBvbiBhbGwgYXV0aG9yaXplZCBjb3BpZXMuG1tLG1syMTs0 SBtbSxtbMjI7NEhUaGlzIGlzIGEgcmVnaXN0ZXJlZCB0cmFkZW1hcmsuG1tLDQo=
mvanle (385 rep)
Jan 13, 2021, 04:28 AM • Last activity: Sep 23, 2024, 03:43 PM
-1 votes
2 answers
351 views
How to print out all printable ASCII strings contained in binary data?
How can I print out all printable ASCII strings (e.g., longer than four chars) contained in a binary file?
How can I print out all printable ASCII strings (e.g., longer than four chars) contained in a binary file?
minto (575 rep)
Jun 16, 2024, 08:35 PM • Last activity: Aug 15, 2024, 01:50 AM
75 votes
3 answers
54135 views
"tree" command output with "pure" (7-bit) ASCII output
The "tree" command uses nice box-drawing characters to show the tree but I want to use the output in a "code-page-neutral" context (I know that really there's always a code page, but by restricting it to the lower characters I hope to be free of worries that someone in Ulan Bator sees smiley faces,...
The "tree" command uses nice box-drawing characters to show the tree but I want to use the output in a "code-page-neutral" context (I know that really there's always a code page, but by restricting it to the lower characters I hope to be free of worries that someone in Ulan Bator sees smiley faces, etc). For example instead of: ├── include │   ├── foo │   └── bar I'd like something like: +-- include | +-- foo | \-- bar but none of the "tree" switch combinations I tried gave this (seems more as if they take the box-drawing chars as the baseline and make it yet prettier) I also looked for box-drawing filters to perform such conversions without finding anything beyond an infinite amount of ASCII art :-). A generic filter smells like something to be cooked-up in 15 mins - plus two more incremental days stumbling into all the amusing corner cases :-)
Tom Goodfellow (957 rep)
Apr 29, 2014, 10:00 AM • Last activity: Feb 12, 2024, 02:14 PM
1 votes
1 answers
104 views
Command similar to ascii for ascii extended and/or for unicode?
`ascii` command in Linux is fast and great. It allows us to search for a character or for a code point and returns all relevant results for a given search. Is there something similar for ASCII extended (e.g.: ISO-8859-1) and/or for Unicode characters?
ascii command in Linux is fast and great. It allows us to search for a character or for a code point and returns all relevant results for a given search. Is there something similar for ASCII extended (e.g.: ISO-8859-1) and/or for Unicode characters?
demacj (13 rep)
Feb 14, 2023, 11:03 AM • Last activity: Feb 14, 2023, 01:36 PM
0 votes
2 answers
542 views
write an ascii extended code to xterm
I can copy and paste text with extended codes into xterm (really xfce4-terminal), and they show up just fine. Piping extended characters to a hex editor shows them just fine for example: " Stéphane " in hex shows as: "53 74 c3 a9 70 68 61 6e 65 0a" -- the accented 'e' is hex: c3 and all's well....
I can copy and paste text with extended codes into xterm (really xfce4-terminal), and they show up just fine. Piping extended characters to a hex editor shows them just fine for example: " Stéphane " in hex shows as: "53 74 c3 a9 70 68 61 6e 65 0a" -- the accented 'e' is hex: c3 and all's well. But I can't figure out how to write an extended code within the xterm. I've tried every variation on: " echo $'\xc3' " but nothing works.
Ray Andrews (2615 rep)
Nov 14, 2022, 08:05 PM • Last activity: Nov 19, 2022, 12:34 PM
2 votes
0 answers
244 views
XTerm: Bitmap font for ASCII, TrueType font for Unicode
I would like to display Chinese characters in the console, with TrueType fonts and normal characters in Bitmap fonts. So far, I have succeeded in displaying: 1. ASCII TrueType, Unicode TrueType (via `XTerm*faceName: DejaVu Sans Mono Book` & `XTerm*faceNameDoubleSize: WenQuanYi Zen Hei Mono`) 2. ASCI...
I would like to display Chinese characters in the console, with TrueType fonts and normal characters in Bitmap fonts. So far, I have succeeded in displaying: 1. ASCII TrueType, Unicode TrueType (via XTerm*faceName: DejaVu Sans Mono Book & XTerm*faceNameDoubleSize: WenQuanYi Zen Hei Mono) 2. ASCII Bitmap, Unicode Bitmap (via XTerm*faceName: Source Code Pro) I found #1 here ($ fc-list :scalable=true:spacing=mono: family which returns the scalable bitmap fonts that may be substituted for TrueType fonts. Source Code Pro has support for Chinese characters. Although, I speculate third possibility, #3, ASCII Bitmap, Unicode TrueType. If a font is chosen without Chinese character support in the faceName resource and a fallback font in the faceNameDoubleSize resource, there would be different fonts displayed at the same time. For some reason, only some Bitmap fonts are Truetype compatible. Why is this? For instance, in the command above, the default fixed font in XTerm is not returned because it is not scalable. If I specify x:fixed or *-fixed-*-*-*-9-* in faceName resource, and WenQuanYi Zen Hei Mono in the faceNameDoubleSize resource, there is no presence of the default fixed font, all text has been replaced with Mono or sorts. Why must it be scalable? I just want to use the font as usual, and rely on another font for the unrecognized characters. It is really a simple request. Summary: I want to specify a bitmap font, indiscriminately, for ASCII characters, as it is when you specify the font or faceName resource (without any following TrueType alternatives listed after since they supersede X fonts), then specify a supporting fallback font for unsupported Unicode characters - by faceNameDoubleSize, wideFont or whatever it is that I am missing.
xascii (21 rep)
Sep 18, 2022, 08:07 PM
0 votes
1 answers
1462 views
is there any way to transfer file in Ascii mode using ftp or sftp
We have a server and we need to transfer file in Ascii mode. While transferring : when we use "ftp" command getting below error Error: 530 Log on attempt by user rejected (530 Secure connection required) or Error: 530 Not logged in. Username/password incorrect, user disabled, or user logged in too m...
We have a server and we need to transfer file in Ascii mode. While transferring : when we use "ftp" command getting below error Error: 530 Log on attempt by user rejected (530 Secure connection required) or Error: 530 Not logged in. Username/password incorrect, user disabled, or user logged in too many times Password is correct as i am able to login using sftp but in sftp not sure how to transfer in ascii mode. Any suggestion pls Pls suggest if there is any reference link to refer
Arya (336 rep)
Jun 26, 2022, 11:10 AM • Last activity: Jun 29, 2022, 10:50 AM
2 votes
1 answers
655 views
ed does not join lines with ASCII text, with CRLF, LF line terminators
I am currently running Gnu ed version 1.18 in the Debian WSL on Windows. If I edit a file with the following encoding: ASCII text, with CRLF, LF line terminators or ASCII text, with CRLF, then ed does not properly join lines with the `j command`. Rather, it deletes the first line meant to be joined....
I am currently running Gnu ed version 1.18 in the Debian WSL on Windows. If I edit a file with the following encoding: ASCII text, with CRLF, LF line terminators or ASCII text, with CRLF, then ed does not properly join lines with the j command. Rather, it deletes the first line meant to be joined. This problem does *not* occur if the file is created in ed, but it does affect files that were created in other programs and are then edited in ed. The same problem is found in GNU ed 1.17. Is this a bug? How would one circumvent this problem?
edman (588 rep)
Jun 25, 2022, 07:46 AM • Last activity: Jun 25, 2022, 10:54 AM
2 votes
1 answers
2253 views
Disabling utf-8 in all terminals?
This question pertains to my Ubuntu 18 system, as follows ... % uname -a Linux myhost.name.net 4.15.0-45-generic #48-Ubuntu SMP Tue Jan 29 16:28:13 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux I don't know how long the following has been going on in the midst of my regular system upgrades, but I have now...
This question pertains to my Ubuntu 18 system, as follows ... % uname -a Linux myhost.name.net 4.15.0-45-generic #48-Ubuntu SMP Tue Jan 29 16:28:13 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux I don't know how long the following has been going on in the midst of my regular system upgrades, but I have now noticed that all my terminal windows are writing UTF-8 characters. I want all terminal windows to use us.ascii (or possibly iso-8859-1). I can't find anywhere where this is set. Furthermore, all keyboard input seems to be coming in as UTF-8, and I also want it to be us.ascii or iso-8859-1. By default, the LANG variable is set to en_US.UTF-8 in all shells that run in my terminal windows, but I am not knowingly setting it that way within any config files. This occurs under xterm, rxvt, and urxvt, and none of these programs are configured to utilize UTF-8, that I know of. I'm running XFCE4, if that makes any difference. I can't find any settings for this in the XFCE4 settings, either. Can anyone suggest a way to reset my system so that all terminal windows always display us.ascii or iso-8859-1, and all keyboard input is also us.ascii or iso-8859-1? Thank you very much.
HippoMan (737 rep)
Mar 17, 2019, 03:26 PM • Last activity: Apr 29, 2022, 01:13 PM
0 votes
2 answers
1573 views
iconv cannot convert from ASCII.. why?
[I have this file.][1] If I open it in Total Commander with `F3` and press `S` the proper content will be shown. I tried to do the same thing in bash with `iconv`: `iconv -f ASCII -t UTF8 input.txt` but I got this: `iconv: illegal input sequence at position 0` If I do from `CP850` or `CP852`: `iconv...
I have this file. If I open it in Total Commander with F3 and press S the proper content will be shown. I tried to do the same thing in bash with iconv: iconv -f ASCII -t UTF8 input.txt but I got this: iconv: illegal input sequence at position 0 If I do from CP850 or CP852: iconv -f CP850 -t UTF8 input.txt iconv -f CP852 -t UTF8 input.txt I will have some unwanted characters in the output: ̦ŮŢŮ How to have the requested content also in Linux Terminal? What encoding is used in Total Commander when it shows ASCII (DOS-charset)? Or is it a bug in iconv?
user3719454 (202 rep)
Apr 21, 2022, 10:06 AM • Last activity: Apr 21, 2022, 10:50 AM
49 votes
6 answers
150227 views
ASCII to Binary and Binary to ASCII conversion tools?
Which is a good tool to convert ASCII to binary, and binary to ASCII? I was hoping for something like: $ echo --binary "This is a binary message" 01010100 01101000 01101001 01110011 00100000 01101001 01110011 00100000 01100001 00100000 01100010 01101001 01101110 01100001 01110010 01111001 00100000 0...
Which is a good tool to convert ASCII to binary, and binary to ASCII? I was hoping for something like: $ echo --binary "This is a binary message" 01010100 01101000 01101001 01110011 00100000 01101001 01110011 00100000 01100001 00100000 01100010 01101001 01101110 01100001 01110010 01111001 00100000 01101101 01100101 01110011 01110011 01100001 01100111 01100101 Or, more realistic: $ echo "This is a binary message" | ascii2bin 01010100 01101000 01101001 01110011 00100000 01101001 01110011 00100000 01100001 00100000 01100010 01101001 01101110 01100001 01110010 01111001 00100000 01101101 01100101 01110011 01110011 01100001 01100111 01100101 And also the reverse: $ echo "01010100 01101000 01101001 01110011 00100000 01101001 01110011 00100000 01100001 00100000 01100010 01101001 01101110 01100001 01110010 01111001 00100000 01101101 01100101 01110011 01110011 01100001 01100111 01100101" | bin2ascii This is a binary message PS: I'm using bash PS2: I hope I didn't get the wrong binary
RSFalcon7 (4477 rep)
Nov 5, 2013, 02:33 PM • Last activity: Apr 2, 2022, 09:58 AM
0 votes
1 answers
1452 views
Unable to change file encoding to utf-8
I modified a `UTF-8` encoded xml file using vi editor and saved it. I'm on Redhat Linux 7.9 I checked the file encoding after the changes and found it to be `us-ascii` file --mime-encoding tmpfiles/08/config/jdbc/jdbc.xml tmpfiles/08/config/jdbc/jdbc.xml: us-ascii I decided to change the encoding ba...
I modified a UTF-8 encoded xml file using vi editor and saved it. I'm on Redhat Linux 7.9 I checked the file encoding after the changes and found it to be us-ascii file --mime-encoding tmpfiles/08/config/jdbc/jdbc.xml tmpfiles/08/config/jdbc/jdbc.xml: us-ascii I decided to change the encoding back to UTF-8 using the below command: iconv -f us-ascii -t UTF-8 tmpfiles/08/config/jdbc/jdbc.xml >tmpfiles/08/config/jdbc/jdbc.xmlenc echo $? 0 However, the encoding for the new file jdbc.xmlenc did not change to UTF-8 and remained unchanged. See the output below: file --mime-encoding tmpfiles/08/config/jdbc/jdbc.xmlenc tmpfiles/08/config/jdbc/jdbc.xmlenc: us-ascii Can you please suggest how can i change the file encoding to UTF-8?
Ashar (527 rep)
Mar 29, 2022, 11:34 AM • Last activity: Mar 29, 2022, 12:24 PM
2 votes
2 answers
1939 views
Why does awk's printf interpret character values greater than 127 as multi-byte characters?
The ASCII character range is from 0 to 127, and within that range, awk's printf with the %c format specifier outputs one byte of data: ``` $ awk 'BEGIN{printf "%c", 97}' a $ awk 'BEGIN{printf "%c", 127}' | xxd 00000000: 7f $ awk 'BEGIN{printf "%c", 127}' | xxd -b 00000000: 01111111 ``` But for value...
The ASCII character range is from 0 to 127, and within that range, awk's printf with the %c format specifier outputs one byte of data:
$ awk 'BEGIN{printf "%c", 97}'
a

$ awk 'BEGIN{printf "%c", 127}' | xxd
00000000: 7f

$ awk 'BEGIN{printf "%c", 127}' | xxd -b
00000000: 01111111
But for values greater than 127, it will print out multiple bytes:
$ awk 'BEGIN{printf "%c", 128}' | xxd
00000000: c280

$ awk 'BEGIN{printf "%c", 128}' | xxd -b
00000000: 11000010 10000000
What is the significance of 0xc280, and why does awk output that character instead of 0x80?
Sam (132 rep)
Jun 18, 2019, 02:52 PM • Last activity: Jan 25, 2022, 12:24 PM
4 votes
1 answers
810 views
grep a range of characters (decimal encoding)
I have a list of accepted characters: !"#$%&'()*+,-./0123456789:; ?@ABCDEFGHI These characters can be translated in the [ASCII decimal range][1] 33-73 The implementation I'd like would parse the lines of an input file, detecting any character out of this range, and returning the corresponding line....
I have a list of accepted characters: !"#$%&'()*+,-./0123456789:;?@ABCDEFGHI These characters can be translated in the ASCII decimal range 33-73 The implementation I'd like would parse the lines of an input file, detecting any character out of this range, and returning the corresponding line. grep -E '[^33-73]{1,}' where -E is for regex interpretation, ^ is for matching any characters NOT in the list, {1,}is for matching one or more occurrences... and [33-73] is a way to symbolize the wanted range of characters in decimal format, I don't know how to express this in a way it's interpretable by grep. (I could define the list of characters in the regex itself, but escaping of reserved grep -E characters makes the expression hard to read.) Is there a way to implement this in grep? (FYI trying to make it work on (BSD grep) 2.5.1-FreeBSD) Example input:
$ cat f1.txt
(ABC123abc_
ABC!123)-
Expected output: (ABC123abc_
aechchiki (243 rep)
Oct 13, 2021, 10:01 AM • Last activity: Oct 13, 2021, 11:53 AM
2 votes
2 answers
989 views
How do I save image produced by asciiview?
When I run command asciiview image.jpg I'm able to view image in the terminal and quit browser using q key. I've tried different ways to redirect the output of the `asciiview image.jpg` to the console output (stdout) or save in the file such as `asciiview image.jpg > ascii_art.txt` or `asciiview -dr...
When I run command asciiview image.jpg I'm able to view image in the terminal and quit browser using q key. I've tried different ways to redirect the output of the asciiview image.jpg to the console output (stdout) or save in the file such as asciiview image.jpg > ascii_art.txt or asciiview -driver stdout image.jpg > ascii_art.txt but I didn't get a result as I'm expecting. In the first case, I had to manually press Ctrl+C to get a proper image in the text file, in the second case I didn't get anything meaningful that would resemble the picture. Have anyone ideas how I can save image produced by asciiview directly to file or display it in the console output without entering browser and having to press q key?
user227030
May 12, 2019, 02:23 AM • Last activity: Oct 7, 2021, 12:42 AM
2 votes
2 answers
12529 views
blessdiff for the "full featured hexadecimal editor"?
I am trying to find some hex diftool which allows me to compare to documents in the view but also the internal differences like in `bless` so two bless windows side-by-side but with diff capability between the windows, at least for selection. I find the `bless - A full featured hexadecimal editor` c...
I am trying to find some hex diftool which allows me to compare to documents in the view but also the internal differences like in bless so two bless windows side-by-side but with diff capability between the windows, at least for selection. I find the bless - A full featured hexadecimal editor could be the best choice here for the integration. Is there any difftool for hex-ascii view in any Linux distro?
Léo Léopold Hertz 준영 (7138 rep)
Jul 22, 2015, 04:43 PM • Last activity: Aug 21, 2021, 07:04 PM
2 votes
2 answers
254 views
combine multiple commands like tr, iconv and dd
New to shell scripting, I have few commands like this. Is it optimal to have such temporary files or should I try to combine all these commands ? if it is latter, can you help me to redirect output from dd command to tr command and then to iconv. Thanks. dd if=abcd.dat cbs=38 conv=block of=abcd.temp...
New to shell scripting, I have few commands like this. Is it optimal to have such temporary files or should I try to combine all these commands ? if it is latter, can you help me to redirect output from dd command to tr command and then to iconv. Thanks. dd if=abcd.dat cbs=38 conv=block of=abcd.temp cat abcd.temp | tr -d "\n" | tr -d "\r" > abcd.output iconv -f ASCII -t EBCDIC-US abcd.ebcdic
Ram (25 rep)
Aug 4, 2021, 08:36 PM • Last activity: Aug 4, 2021, 09:08 PM
0 votes
1 answers
3095 views
what does the following tr command do?
I am looking at a .sh script and one of the lines is the following: ``` tr -d '\15' /testProject/files/file1.txt ``` i understood the part `file1.txt > /testProject/files/file1.txt` which means to add the result to /testProject/files/file1.txt but what does `tr -d '\15' < file1.txt` do? I know \15 i...
I am looking at a .sh script and one of the lines is the following:
tr -d '\15'  /testProject/files/file1.txt
i understood the part file1.txt > /testProject/files/file1.txt which means to add the result to /testProject/files/file1.txt but what does tr -d '\15' < file1.txt do? I know \15 is an ASCAII character but not sure what it does. Would really appreciate if someone could help.
Amreen Fatema (11 rep)
Jun 23, 2021, 11:17 AM • Last activity: Jun 23, 2021, 11:48 AM
18 votes
7 answers
69746 views
How do I print an ASCII character by different code points in Bash?
In the ASCII table the 'J' character exists which has code points in different numeral systems: Oct Dec Hex Char 112 74 4A J It's possible to print this char by an octal code point by printing `printf '\112'` or `echo $'\112'`. How do I print the same character by decimal and hexadecimal code point...
In the ASCII table the 'J' character exists which has code points in different numeral systems: Oct Dec Hex Char 112 74 4A J It's possible to print this char by an octal code point by printing printf '\112' or echo $'\112'. How do I print the same character by decimal and hexadecimal code point presentations?
viavad (343 rep)
Sep 23, 2016, 04:09 PM • Last activity: Jun 9, 2021, 05:55 PM
Showing page 1 of 20 total questions