05-27-2014
This is not a little different. There is a HUGE difference between changing all "|" characters after the first 3 on a line to "_" characters and changing an unknown number of "|" characters in the middle of a line to some other unspecified character(s).
What are the exact field widths for this new file format (or what is the format of the file that specifies the file format for the file(s) you want to process)? Are embedded "|" characters all supposed to be changed to "_", or is a different character used in some fields? Do all fields need to be checked? If not, how will your script know which fields should be checked?
What have you tried to solve this problem?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am using sed to replace things like "," and tabs in a file, but what is the code for replacing a \ ???? (5 Replies)
Discussion started by: rjsha1
5 Replies
2. UNIX for Dummies Questions & Answers
Hi All,
I am facing a strange situation and want to find why it is occuring . When i convert the whole line into Hexadecimal character i can find the junk value after new line (\n) . If i look in binary mode it is not visible.
PLease let me know how possible the junk character is added... (1 Reply)
Discussion started by: arunkumar_mca
1 Replies
3. Shell Programming and Scripting
Hi All,
I'm trying to write a ksh script to parse a file. When the "\" character is encountered, it should be removed and the next line should be concatenated with the current line. For example...
this is a test
line #1\
should be concatenated with line #2\
and line number 3
when this... (3 Replies)
Discussion started by: newbie_coder
3 Replies
4. UNIX for Dummies Questions & Answers
Hi!!..
I would like to know what is maximum character size for a command in the "sh" or "bourne" shell?
Thanks in advance..
Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies
5. UNIX for Advanced & Expert Users
Hi!!..
I would like to know what is maximum character size for a command in the "sh" or "bourne" shell?
Thanks in advance..
Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies
6. Shell Programming and Scripting
Hi!!..
I would like to know what is maximum character size for a command in the "sh" or "bourne" shell?
Thanks in advance..
Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies
7. Shell Programming and Scripting
Hi,
My input has much more lines, but few of them are below
pin(IDF) {
direction : input;
drc_pinsigtype : signal;
pin(SELDIV6) {
direction : input;
drc_pinsigtype : ... (3 Replies)
Discussion started by: nehashine
3 Replies
8. Shell Programming and Scripting
Hello everyone
Sorry I have to add another sed question. I am searching a log file and need only the first 2 occurances of text which comes after (note the space) "string " and before a ",". I have tried
sed -n 's/.*string \(*\),.*/\1/p' filewith some, but limited success. This gives out all... (10 Replies)
Discussion started by: haggismn
10 Replies
9. UNIX for Dummies Questions & Answers
Hi All
It's me again with another huge txt files. :confused:
What I have:
- I have 33 huge txt files in a folder.
- I have thousands of line in this txt file which contain many the letter "x" in them.
- Some of them have more than one "x" character in the line.
What I want to achieve:... (8 Replies)
Discussion started by: Nexeu
8 Replies
10. Shell Programming and Scripting
I'd like to put paragraph breaks \n\n randomly between 5 - 10 occurrences of the dot character (.), for an entire text file. How to do that?
In other words, anywhere between every 5 -10 sentences, a new paragraph will generate. There are no other uses of the (.) except for sentence breaks in... (11 Replies)
Discussion started by: p1ne
11 Replies
magic(4) Kernel Interfaces Manual magic(4)
NAME
magic - Magic file for the file command
SYNOPSIS
/etc/magic
DESCRIPTION
The magic file is used by the file command to identify files that have some sort of magic number. A magic number is any numeric or string
constant that identifies the file containing the constant.
The format for the magic file is as follows:
offset type operator,value string
The fields should be separated by tabs. Each record must be contained on one line.
The fields contain the following data: This field contains the number of bytes from the beginning of the file on which you are running the
file command to the first byte of the magic number of character string you want to identify. Use a right angle bracket (>) to indicate a
continuation line that supplies additional information describing the file. This field contains information about the data type of the
magic number or character string at the specified byte offset. Valid data types for this field are: Unsigned character type Unsigned short
type Long type Character (byte) string This field contains instructions for the file command on how to compare the value read from the file
being checked with the value stored in the Value Type field of the magic file. The valid comparison operators are: The two values are
equal. The value in the file being checked is greater than the value in the magic file. The value in the file being checked is less than
the value in the magic file. All the bits in the magic file value must be set in the value from the file being checked.
Note that the Comparison Operator field is optional. If you do not specify the operator, the values are expected to be equal. This
field contains the value used to compare what is read from the file being checked by the file command. You can use decimal, hex, or
octal numbers in this field or character strings in the form of regular expressions.
Precede all hex numbers with the characters zero and x (for example, 0x80). To specify an octal number, precede it with a zero (for
example, 0200). Decimal numbers require no special representation and should be written as integers (for example, 128).
The rules for specifying character strings follow those of the ed editor (see ed(1)) for regular expressions, with two extensions:
You use the backslash () to escape an unprintable character. The string can contain all special character such as
, ,
, and
f. If a backslash appears in the string, it must be escaped with a second backslash (\). You can use octal representation to
specify any byte value other than zero (0). Text found in the file can be inserted into the printed string if it is preceded and
followed by \% delimiters. All text found between these delimiters is displayed as the print string.
This regular expression search never terminates until a match is explicitly found or rejected. The special character
is a valid
character in the patterns. Therefore, the pattern .* should never be used here. This field contains the string to print. The
string provides information about the file. The string can include text found in the file when requested with an appropriate
printf() format.
EXAMPLES
The following is an example of a script: string ^#!{ }*\%[^
]*\% %s
The following are examples of executable images: >2 short 02 POSIX >2 short 01 SVID
>16 long >0 not stripped
The following are examples of text and data files: 0 string ^ 1h[0-9][0-9][0-9][0-9][0-9] sccsfile 0 string ^#ifndef
c program 0 string ^070707 ASCII cpio archive
FILES
/etc/magic
RELATED INFORMATION
Commands: file(1) delim off
magic(4)