Sponsored Content
Top Forums Shell Programming and Scripting Convert Windows Metacharacters to Regular Text Post 302472630 by Chubler_XL on Wednesday 17th of November 2010 04:59:37 PM
Old 11-17-2010
Here is a solution that uses bash arrays (easier to extend for other chars you find - like A9 for the copyright symbol).

Code:
#!/bin/bash
src=(85 92 93 94 A9)
dest=("..." \' \" \" "(c)")
for((i=0;i<${#src[@]};i++)) {
   SEDSTR="${SEDSTR};$(printf "s/%c/%s/" $(echo -e \\x${src[i]}) ${dest[i]})"
}
sed -i $SEDSTR myfile.txt


Last edited by Chubler_XL; 11-17-2010 at 06:12 PM.. Reason: Fix formatting
This User Gave Thanks to Chubler_XL For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How do I convert unix text to to win text?

How do I convert unix text files into readable text for windows. Dave (1 Reply)
Discussion started by: nucca
1 Replies

2. Solaris

convert windows OS as Solaris remotely

I have a Windows 2000 Terminal, which I want to convert into Solaris 10. I am connected to windows terminal remotely via iLO and then inserted the solaris DVD in my local drive. Now when I connect to Windows machine from 'RDP' - I can see local DVD in there - and IF I then reboot remote machine... (1 Reply)
Discussion started by: panchpan
1 Replies

3. UNIX for Dummies Questions & Answers

How to convert text to columns in tab delimited text file

Hello Gurus, I have a text file containing nearly 12,000 tab delimited characters with 4000 rows. If the file size is small, excel can convert the text into coloumns. However, the file that I have is very big. Can some body help me in solving this problem? The input file example, ... (6 Replies)
Discussion started by: Unilearn
6 Replies

4. Shell Programming and Scripting

How can I get the matched text when using regular expression.

Hello: (exp) : match "exp",the matched text is stored in auto named arrays. How can I get the matched text ? What is the name of the auto named arrays on linux shell ? (4 Replies)
Discussion started by: 915086731
4 Replies

5. UNIX for Dummies Questions & Answers

Copying text from Windows to AIX - missing text?

Hi All, I'm hoping this is an easy question, but I'm having a weird problem trying to simply copy and paste text from MS Windows (XP) Notepad and then pasting into vi or vim in AIX. When I type "oslevel" I get "5.3.0.0". The problem is that once the text is pasted, there are sections of text... (2 Replies)
Discussion started by: PlainInverted
2 Replies

6. Shell Programming and Scripting

help with organizing some non regular text

hey im trying to get the hex diffrences in two files ones called new and the other is named old i want it to phrase into my script, heres how i need the info: input='\x'94 #the new 1 byte hex change offset=00000000 #the 1st offset of the difference patch unset input offset input='\x'34... (5 Replies)
Discussion started by: lewisdenny
5 Replies

7. Shell Programming and Scripting

Convert this Windows script so I can use it on Macbook

Hi guys, I am been banging my head for days on something that appears too simple to be so hard for me. I have this bash script which I used just fine on my windows PC. I took this file over to my Macbook and try to run it and it fails like no tomorrow. This is the contents of the file:... (3 Replies)
Discussion started by: richsark
3 Replies

8. Windows & DOS: Issues & Discussions

Convert UNIX text file in Windows to recognize line breaks

Hmmm I think I found the correct subforum to ask my question... I have some text files that I prepared in vi some time ago, and now I want to open and edit them with Windows Notepad. I don't have a Unix terminal at the moment so I need to do the conversion in Windows. Is there a way to do this?... (1 Reply)
Discussion started by: frys_hp
1 Replies

9. UNIX for Dummies Questions & Answers

Convert UNIX text file in Windows to recognize line breaks

Hi all, I have some text files that I prepared in vi some time ago, and now I want to open and edit them with Windows Notepad. I don't have a Unix terminal at the moment so I need to do the conversion in Windows. Is there a way to do this? Or just reinsert thousands of line breaks again :eek: ? (2 Replies)
Discussion started by: frys_hp
2 Replies

10. Shell Programming and Scripting

Trying to convert utf-8 to WINDOWS-1251

Hello all i have utf-8 file that i try to convert to WINDOWS-1251 on linux without any success the file name is utf-8 when i try to do : file -bi test.txt it gives me : text/plain; charset=utf-8 when i try to convert the file i do : /usr/bin/iconv -f UTF-8 -t WINDOWS-1251 test.txt >... (1 Reply)
Discussion started by: umen
1 Replies
shells(4)							   File Formats 							 shells(4)

NAME
shells - shell database SYNOPSIS
/etc/shells DESCRIPTION
The shells file contains a list of the shells on the system. Applications use this file to determine whether a shell is valid. See getuser- shell(3C). For each shell a single line should be present, consisting of the shell's path, relative to root. A hash mark (#) indicates the beginning of a comment; subsequent characters up to the end of the line are not interpreted by the routines which search the file. Blank lines are also ignored. The following default shells are used by utilities: /bin/bash, /bin/csh, /bin/jsh, /bin/ksh, /bin/ksh93, /bin/pfcsh, /bin/pfksh, /bin/pfsh, /bin/sh, /bin/tcsh, /bin/zsh, /sbin/jsh, /sbin/sh, /usr/bin/bash, /usr/bin/csh, /usr/bin/jsh, /usr/bin/ksh, /usr/bin/ksh93, /usr/bin/pfcsh, /usr/bin/pfksh, /usr/bin/pfsh, and /usr/bin/sh, /usr/bin/tcsh, /usr/bin/zsh, and /usr/sfw/bin/zsh. /etc/shells overrides the default list. Invalid shells in /etc/shells could cause unexpected behavior, such as being unable to log in by way of ftp(1). FILES
/etc/shells list of shells on system SEE ALSO
vipw(1B), ftpd(1M), sendmail(1M), getusershell(3C), aliases(4) SunOS 5.11 20 Nov 2007 shells(4)
All times are GMT -4. The time now is 02:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy