Sponsored Content
Top Forums Shell Programming and Scripting Lines with strange characters and sed... Post 302253252 by joeyg on Friday 31st of October 2008 09:17:04 AM
Old 10-31-2008
Hammer & Screwdriver There are some special character classes

Sometimes hard to test a file with strange characters without the file, but consider the following:

You may have seen where you can
Code:
echo "hello" | tr [:lower:] [:upper:]
HELLO

but there are others
[:alnum:] for printable characters
[:cntrl:] for control characters

Perhaps using one of the above might allow you to strip off the bad, or only carry forward the good characters.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Strange Characters in Filename

Hi folks. None of the conventional methods are working for my dilemma: I have a file in my root directory that has a name comprised of strange characters. When I do an ls, it just hangs at that file until I do a Cntrl-C. rm ./filename & rm \filename do not work. I am entering the... (4 Replies)
Discussion started by: kristy
4 Replies

2. Shell Programming and Scripting

Split a huge line into multiple 120 characters lines with sed?

Hello , I'm trying to split a file which contains a single very long line. My aim is to split this single line each 120 characters. I tried with the sed command : `cat ${MYPATH}/${FILE}|sed -e :a -e 's/^.\{1,120\}$/&\n/;ta' >{MYPATH}/${DEST}` but when I wc -l the destination file it is... (2 Replies)
Discussion started by: jerome_1664
2 Replies

3. Shell Programming and Scripting

Strange Characters After Using Notepad

Hello all, I'm new to UNIX and new to this forum, so forgive my lack of knowledge. I'm new with editing in vi so I FTP scripts to a Windows machine and edit the script in notepad (when I need to do something quickly). Sometimes when I FTP the script back to the UNIX box, strange characters... (4 Replies)
Discussion started by: dgower2
4 Replies

4. Shell Programming and Scripting

Sed - merge lines bw 2 specific characters

Hi, I have a bash script and I am looking for a command that will merge specific lines together. Sample Data: registration time = 1300890272 Id = 1 setd = 0 tagunt = 26 tagId=6, length=8, value= tagId=9, length=5, value= tagId=7, length=2, value= tagId=16, length=2, value= tagId=32,... (8 Replies)
Discussion started by: Winsarc
8 Replies

5. Shell Programming and Scripting

awk filelist containing strange characters

I've written a script: find -depth | awk ‘ { if ( substr($1,length($0)-2,3) == “/1.” ) { print $1 } { system(“awk -f test1.awk “ $1 ) } } ‘ The idea is that it trundles through a large directory structure looking for files which are named '1.' and then... (3 Replies)
Discussion started by: nashcom
3 Replies

6. Shell Programming and Scripting

Grep a file that may contain strange characters

Hello unix users :) I am trying to grep a string from a file that both the file and the string may have characters in them that are quite... strange, like würzburger. Well, bash reads this as W%C3%BCrzburger For example, if i do wget W%C3%BCrzburger the output is: --2012-01-08... (2 Replies)
Discussion started by: hakermania
2 Replies

7. Red Hat

Spanish Characters get converted in strange chrac

I am trying to sftp a textfile from windows to linux. The file includes some spanish characters. When I vi the file in LINUX, the special (spanish) characters get converted into some strange characters. anyone know how i can resolve this? for example México gets converted into México on LINUX. (0 Replies)
Discussion started by: mrx1350
0 Replies

8. Hardware

Strange Characters from ILOM

Hello, I have an x86 server with an ILOM connection that produces strange characters when I perform a start /SP/console, see below: Oracle(R) Integrated Lights Out Manager Version 3.0.16.10.a r68533 Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. -> start... (9 Replies)
Discussion started by: kerrygold
9 Replies

9. Shell Programming and Scripting

sed replacing specific characters and control characters by escaping

sed -e "s// /g" old.txt > new.txt While I do know some control characters need to be escaped, can normal characters also be escaped and still work the same way? Basically I do not know all control characters that have a special meaning, for example, ?, ., % have a meaning and have to be escaped... (11 Replies)
Discussion started by: ijustneeda
11 Replies

10. Programming

Strange characters in FORTRAN code output

Hi guys, After compiling a .f90 code and executing it, i get strange characters in the output file like : ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ Are these windows characters? how can i get rid of this? Much appreciated. Paul (1 Reply)
Discussion started by: Paul Moghadam
1 Replies
SHAR(1net)							  Wang Institute							SHAR(1net)

NAME
shar - create file storage archive for extraction by /bin/sh SYNOPSIS
shar [-abcmsuv] [-p prefix] [-d delim] files > archive DESCRIPTION
shar prints its input files with special command lines around them to be used by the shell, /bin/sh , to extract the files later. The out- put can be filtered through the shell to recreate copies of the original files. shar allows directories to be named, and shar prints the necessary commands (mkdir & cd) to create new directories and fill them. shar will not allow existing files to be over-written; such files must be removed by the user extracting the files. OPTIONS
-a All the options. The options: -v -c -b -p <tab>X are implied. -b Extract files into basenames so that files with absolute path names are put into the current directory. This option has strange effects when directories are archived. -c Check file size on extraction by counting characters. An error message is reported to the person doing the extraction if the sizes don't match. One reason why the sizes may not match is that shar will append a newline to complete incomplete last lines; shar prints a message that mentions added newlines. Another reason why the sizes may not match is that some network mail programs remove non-whitespace control characters. shar prints a message that mentions control characters to the extractor. -d Use this as the ``end of file'' delimiter instead of the default. The only reason to change it is if you suspect a file contains the default delimiter: SHAR_EOF. -m Reset the exact protection modes of files when they are extracted (using the chmod program). By default, the extractor's default file modes are used, and executable files (e.g., shell scripts) are made executable. -p Use this as the prefix to each line of the archived files. This is to make sure that special characters at the start of lines are not eaten up by programs like mailers. If this option is used, the files will be extracted with the stream editor sed rather than cat so it is more efficient and portable to avoid setting the prefix, though perhaps less safe if you don't know what is in the files. -s Silent running. All checking and extra output is inhibited. -u Archive the input files with the uuencode format for later extraction with uudecode. This will allow you to send files with control characters in them, but will slow down the extracting. You must be sure that the receiving party has access to uudecode. -v Print verbose feedback messages about what shar is doing to be printed during extraction. Sizes of plain files are echoed to allow a simple validity check. SEE ALSO
sh(1), tar(1), cpio(1), tp(1), uuencode(1), uudecode(1) fpack(1) is a plain-file packer useful for UNIX and MSDOS AUTHOR
Gary Perlman (based on a shell version by James Gosling, with additions motivated by many people on the UNIX network: Derek Zahn, Michael Thompson, H. Morrow Long, Fred Avolio, Gran Uddeborg, Chuck Wegrzyn, nucleus!randy@TORONTO, & Bill McKeeman) LIMITATIONS
shar does not know anything about links between files. UNIX User's Manual March 4, 1986 SHAR(1net)
All times are GMT -4. The time now is 04:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy