Sponsored Content
Top Forums Shell Programming and Scripting How to replace special characters? Post 302724259 by ctsgnb on Wednesday 31st of October 2012 12:13:32 PM
Old 10-31-2012
Code:
$ seq -f "%03g" 0 400 | while read i; do echo -e "code $i : \0$i"; done | cat -v | grep 'M-^E'
code 205 : M-^E

Looking especially for those having long sequences and filtering out those that are ending with figures:

Code:
$ seq -f "%03g" 0 400 | while read i; do echo -e "code $i : \0$i"; done | cat -v | awk 'length($0)>12&&$0!~/.*[0-9]+$/' | pr -5 -s'  ' -t
code 000 : ^@    code 177 : ^?    code 235 : M-^]    code 305 : M-E    code 343 : M-c
code 001 : ^A    code 200 : M-^@    code 236 : M-^^    code 306 : M-F    code 344 : M-d
code 002 : ^B    code 201 : M-^A    code 237 : M-^_    code 307 : M-G    code 345 : M-e
code 003 : ^C    code 202 : M-^B    code 240 : M-     code 310 : M-H    code 346 : M-f
code 004 : ^D    code 203 : M-^C    code 241 : M-!    code 311 : M-I    code 347 : M-g
code 005 : ^E    code 204 : M-^D    code 242 : M-"    code 312 : M-J    code 350 : M-h
code 006 : ^F    code 205 : M-^E    code 243 : M-#    code 313 : M-K    code 351 : M-i
code 007 : ^G    code 206 : M-^F    code 244 : M-$    code 314 : M-L    code 352 : M-j
code 010 : ^H    code 207 : M-^G    code 245 : M-%    code 315 : M-M    code 353 : M-k
code 013 : ^K    code 210 : M-^H    code 246 : M-&    code 316 : M-N    code 354 : M-l
code 014 : ^L    code 211 : M-^I    code 247 : M-'    code 317 : M-O    code 355 : M-m
code 015 : ^M    code 212 : M-^J    code 250 : M-(    code 320 : M-P    code 356 : M-n
code 016 : ^N    code 213 : M-^K    code 251 : M-)    code 321 : M-Q    code 357 : M-o
code 017 : ^O    code 214 : M-^L    code 252 : M-*    code 322 : M-R    code 360 : M-p
code 020 : ^P    code 215 : M-^M    code 253 : M-+    code 323 : M-S    code 361 : M-q
code 021 : ^Q    code 216 : M-^N    code 254 : M-,    code 324 : M-T    code 362 : M-r
code 022 : ^R    code 217 : M-^O    code 255 : M--    code 325 : M-U    code 363 : M-s
code 023 : ^S    code 220 : M-^P    code 256 : M-.    code 326 : M-V    code 364 : M-t
code 024 : ^T    code 221 : M-^Q    code 257 : M-/    code 327 : M-W    code 365 : M-u
code 025 : ^U    code 222 : M-^R    code 272 : M-:    code 330 : M-X    code 366 : M-v
code 026 : ^V    code 223 : M-^S    code 273 : M-;    code 331 : M-Y    code 367 : M-w
code 027 : ^W    code 224 : M-^T    code 274 : M-<    code 332 : M-Z    code 370 : M-x
code 030 : ^X    code 225 : M-^U    code 275 : M-=    code 333 : M-[    code 371 : M-y
code 031 : ^Y    code 226 : M-^V    code 276 : M->    code 334 : M-\    code 372 : M-z
code 032 : ^Z    code 227 : M-^W    code 277 : M-?    code 335 : M-]    code 373 : M-{
code 033 : ^[    code 230 : M-^X    code 300 : M-@    code 336 : M-^    code 374 : M-|
code 034 : ^\    code 231 : M-^Y    code 301 : M-A    code 337 : M-_    code 375 : M-}
code 035 : ^]    code 232 : M-^Z    code 302 : M-B    code 340 : M-`    code 376 : M-~
code 036 : ^^    code 233 : M-^[    code 303 : M-C    code 341 : M-a    code 377 : M-^?
code 037 : ^_    code 234 : M-^\    code 304 : M-D    code 342 : M-b    code 400 : ^@


Last edited by ctsgnb; 10-31-2012 at 02:06 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Replace Special characters in a file

Hi, I have a data like this in a file, 402003279034002000100147626030003300010000000000002000029000000 ær^M^\MÍW^H I need to replace those special char to some other char like # or $ Is there any ways to do it... I tried commands tr,sed and many but it was not able to replace because... (1 Reply)
Discussion started by: solai
1 Replies

2. UNIX for Dummies Questions & Answers

Find and replace special characters in a file

HI All I need a shell script ehich removes all special characters from file and converts the file to UTF-* format Specail characters to be removed must be configurable. strIllegal = @"?/><,:;""'{|\\+=-)(*&^%$#@!~`"; Please help me in getting this script as my scripting skilla are... (2 Replies)
Discussion started by: sujithchandra
2 Replies

3. Shell Programming and Scripting

Using sed to replace special characters

Hi everyone I have file1 contains: '7832' ' 8765 6543 I want a sed command that will format as: '7832' , '8765' , '6543' I tried sed -e s/\'//g -e 's/^*//;s/*$//' file1 > file2 sed -e :a -e '$!N; s/\n/ /; ta' file2 which gives: 7832 8765 6543 I need some help to continue with... (5 Replies)
Discussion started by: nimo
5 Replies

4. Solaris

How to replace special characters in vi?

Hi , I want to replace the special characters in the file. For eg: cat abc 1234/4455/acb 234/k/lll/ 234`fs`fd I want to replace / and ` with the letter a and the output should like below. How to achieve this. 1234a4455aacb 234akallla 234afsafd (2 Replies)
Discussion started by: rogerben
2 Replies

5. Shell Programming and Scripting

Replace special characters

I have a line ending with special character and 0 The special character is the field separator for this line in VI mode the file will look like below, but while cat the special character wont display i know the hexa code for the special character ^_ is \x1f and ascii code is \0037, ... (0 Replies)
Discussion started by: ratheeshjulk
0 Replies

6. Shell Programming and Scripting

Replace special characters with Escape characters?

i need to replace the any special characters with escape characters like below. test!=123-> test\!\=123 !@#$%^&*()-= to be replaced by \!\@\#\$\%\^\&\*\(\)\-\= (8 Replies)
Discussion started by: laknar
8 Replies

7. Shell Programming and Scripting

Replace special characters with backslash and character

Hi, I have a string wherein i need to replace special characters with backslash and that character. Ex: If my string is a=qwerty123@!, then the new string should be a_new=qwerty123\@\!\, Thanks (3 Replies)
Discussion started by: temp_user
3 Replies

8. Shell Programming and Scripting

Help to replace the string with special characters

{"name":"alR_pl-ENVIRONMENT_192_168_211_123_sDK_PROVISION_7","description":"aLR_pl-ENVIRONMENT_192_168_211_123_sDK_PROVISION_7","json_class":"Chef::Role","default_attributes":{},"override_attributes":{"yoapp":{"jboss":"5.1.0","port":"2243","warname":"soap","datacenter":"alR","ip":"192.168.211.123","... (3 Replies)
Discussion started by: nikhil jain
3 Replies

9. UNIX for Advanced & Expert Users

How to replace special characters?

Hi Team, I have data like this. |*|.5|*|0.2|*|A.B|*| Would like to add zero (0) before the decimal point where there is no zero as |*|0.5|*|0.2|*|A.B|*| How to replace |*|. with |*|0. I tried below command which didn't work echo '|*|.5|*|0.2|*|A.B|*' | sed... (4 Replies)
Discussion started by: Ravi.K
4 Replies

10. UNIX for Beginners Questions & Answers

Replace Pattern with another that has Special Characters

Hello Team, Any help would be much appreciated for the below scenario: I have a sed command below where I am trying to replace the contents of 'old_pkey' variable with 'new_pkey' variable in a Soap request file (delete_request.txt). This works fine for regular string values, but this new_pkey... (8 Replies)
Discussion started by: ChicagoBlues
8 Replies
unix2dos(1)						      General Commands Manual						       unix2dos(1)

NAME
unix2dos - UNIX to DOS text file format converter SYNOPSYS
unix2dos [options] [-c convmode] [-o file ...] [-n infile outfile ...] Options: [-hkqV] [--help] [--keepdate] [--quiet] [--version] DESCRIPTION
This manual page documents unix2dos, the program that converts text files in UNIX format to DOS format. OPTIONS
The following options are available: -h --help Print online help. -k --keepdate Keep the date stamp of output file same as input file. -q --quiet Quiet mode. Suppress all warning and messages. -V --version Prints version information. -c --convmode convmode Sets conversion mode. Simulates unix2dos under SunOS. -o --oldfile file ... Old file mode. Convert the file and write output to it. The program default to run in this mode. Wildcard names may be used. -n --newfile infile outfile ... New file mode. Convert the infile and write output to outfile. File names must be given in pairs and wildcard names should NOT be used or you WILL lost your files. EXAMPLES
Get input from stdin and write output to stdout. unix2dos Convert and replace a.txt. Convert and replace b.txt. unix2dos a.txt b.txt unix2dos -o a.txt b.txt Convert and replace a.txt in ASCII conversion mode. Convert and replace b.txt in ISO conversion mode. unix2dos a.txt -c iso b.txt unix2dos -c ascii a.txt -c iso b.txt Convert and replace a.txt while keeping original date stamp. unix2dos -k a.txt unix2dos -k -o a.txt Convert a.txt and write to e.txt. unix2dos -n a.txt e.txt Convert a.txt and write to e.txt, keep date stamp of e.txt same as a.txt. unix2dos -k -n a.txt e.txt Convert and replace a.txt. Convert b.txt and write to e.txt. unix2dos a.txt -n b.txt e.txt unix2dos -o a.txt -n b.txt e.txt Convert c.txt and write to e.txt. Convert and replace a.txt. Convert and replace b.txt. Convert d.txt and write to f.txt. unix2dos -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt DIAGNOSTICS
BUGS
The program does not work properly under MSDOS in stdio processing mode. If you know why is that so, please tell me. AUTHOR
Benjamin Lin - ( blin@socs.uts.edu.au ) MISCELLANY
Tested environment: Linux 1.2.0 with GNU C 2.5.8 SunOS 4.1.3 with GNU C 2.6.3 MS-DOS 6.20 with Borland C++ 4.02 Suggestions and bug reports are welcome. SEE ALSO
dos2unix(1) 1995.03.31 unix2dos v2.2 unix2dos(1)
All times are GMT -4. The time now is 07:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy