Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Replace Special characters in a file Post 302079872 by jim mcnamara on Thursday 13th of July 2006 10:36:05 AM
Old 07-13-2006
You can use POSIX character classes with tr
Code:
tr -s '[:cntrl:]' '#' < filename   > newfilename

This converts all of the control characters (those ^M, etc) characters to a # in filename then writes the output to newfilename.
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. Shell Programming and Scripting

How to replace special characters?

Hi Unix Guru, I have an requirement for replace some specail characters in a file, my file came from mainframe. please see below example: when open it with vi 17896660|89059215|04/24/1998 00:00:00.000000| abc 123-453-1312^M<85>^M<85>|124557 if I run cat -v I got following:... (25 Replies)
Discussion started by: ken002
25 Replies

7. 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

8. UNIX for Dummies Questions & Answers

Search special characters in a file and replace with meaningful text messages like Hello

Search special characters in a file and replace with meaningful text messages like Hello (2 Replies)
Discussion started by: raka_rjit
2 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
SETQUOTA(2)							System Calls Manual						       SETQUOTA(2)

NAME
setquota - enable/disable quotas on a file system SYNOPSIS
setquota(special, file) char *special, *file; DESCRIPTION
Disc quotas are enabled or disabled with the setquota call. Special indicates a block special device on which a mounted file system exists. If file is nonzero, it specifies a file in that file system from which to take the quotas. If file is 0, then quotas are disabled on the file system. The quota file must exist; it is normally created with the quotacheck(8) program. Only the super-user may turn quotas on or off. SEE ALSO
quota(2), quotacheck(8), quotaon(8) RETURN VALUE
A 0 return value indicates a successful call. A value of -1 is returned when an error occurs and errno is set to indicate the reason for failure. ERRORS
Setquota will fail when one of the following occurs: [ENOTDIR] A component of either path prefix is not a directory. [EINVAL] Either pathname contains a character with the high-order bit set. [EINVAL] The kernel has not been compiled with the QUOTA option. [ENAMETOOLONG] A component of either pathname exceeded 255 characters, or the entire length of either path name exceeded 1023 characters. [ENODEV] Special does not exist. [ENOENT] File does not exist. [ELOOP] Too many symbolic links were encountered in translating either pathname. [EPERM] The caller is not the super-user. [ENOTBLK] Special is not a block device. [ENXIO] The major device number of special is out of range (this indicates no device driver exists for the associated hardware). [EROFS] File resides on a read-only file system. [EACCES] Search permission is denied for a component of either path prefix. [EACCES] File resides on a file system different from special. [EACCES] File is not a plain file. [EIO] An I/O error occurred while reading from or writing to the file containing the quotas. [EFAULT] Special or path points outside the process's allocated address space. BUGS
The error codes are in a state of disarray; too many errors appear to the caller as one value. 4.2 Berkeley Distribution August 26, 1985 SETQUOTA(2)
All times are GMT -4. The time now is 06:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy