Magic numbers string/B problem


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Magic numbers string/B problem
# 1  
Old 07-08-2011
Magic numbers string/B problem

Hello,

In manpage magic(5)
"
The “B” flag compacts whitespace in the target, which must contain at least one whitespace character. If the magic has n consecutive blanks, the target needs at least n consecutive blanks to match. The “b” flag treats every blank in the target as an optional blank. " is writing for string/B type.
I create a magic.mime with a line

"0 string/B melemen\ 123\ \ abc filedetected"


and first line of myfile is "melemen 123 abc" //Note: there are at least two blanks between 123 and abc but not appear here.

when my data in magic file is like that "melemen\ 123\ abc" it prints "filedetected" but when there are two blank between
123 and abc like "123\ \ abc" it does not work.However according to explanation it sohuld be work. I do not understand where I am wrong.


My second problem is about ampersand
what does "&" mean when it is used at the begining of offsets like

0 string ...
>4 string...
>>&0 string....



There is not enough information about magic operators on the internet so sometimes I have difficulty understanding functionality of operators.

Last edited by segmentation; 07-08-2011 at 11:35 AM.. Reason: revise
# 2  
Old 07-08-2011
magic only works when the OS is invoking a new file via exec().
It is used to tell the system what interpreter to run or how to load the file into memory.

Some systems extend this (Solaris is one) to be able to identify all kinds of file types -- using the file command -- which do not really fit into the above statement.

1. what are you trying to do?
2. what OS (each OS has different ideas about magic)?
# 3  
Old 07-08-2011
I am trying to implement a program in erlang which detects file types.I am using unix's database magic.mime and its syntax.My system is ubuntu.
# 4  
Old 07-08-2011
You have two consecutive blanks...so do you have 2 consecutive /B to match them as per the manpage.
# 5  
Old 07-08-2011
I don't understand what do you mean with 2 consecutive /B. I tried string/BB and
string/B/B and some other combinations but no result.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Magic numbers '&' operator problem

Hello everyone, on the man page of "magic(5)" There is explanation "&, to specify that the value from the file must have set all of the bits that are set in the specified value" . My question is that what is the difference between '&' and equal operator '=' ? I tested it with file... (6 Replies)
Discussion started by: segmentation
6 Replies

2. UNIX for Dummies Questions & Answers

Extracting numbers from a String

Hi all, I'm a new programmer to shell script... and I have no idea how to use substring. I want to extract the numbers from the following string and place it into a variable: "170 unique conformations found" The numbers can be more than three digits depending on the case. I just want to... (10 Replies)
Discussion started by: ah7391
10 Replies

3. UNIX for Dummies Questions & Answers

Solaris magic number problem

Hello, When I boot up my ancient SUNOS 5 system. it stops at the OK prompt and complains about a bad magic number. I have told that I need run fsck but I cannot seem to do so from the OK prompt. How can I get into a diagnostic mode so I can run fsck? Thanks, (1 Reply)
Discussion started by: mojoman
1 Replies

4. Shell Programming and Scripting

get partial numbers from a string

Hi Everyone, I have: $val="QQ3_1899_CD4". The output will be: 1899. I did $val =~ /(\d+)/g; the output is 318994, then i use substr to get those 1899. This is not efficient. Is any simple way, like just one line can do? Thanks (1 Reply)
Discussion started by: jimmy_y
1 Replies

5. UNIX for Dummies Questions & Answers

Using Floating Numbers in String

Dear Unix Gurus, I have a list of files that I want to loop over....for example: sl40_z11.70.txt sl41_z11.40.txt sl42_z11.10.txt sl43_z10.80.txt using the script #!/bin/sh # echo -n "....enter first Z-coordinate position....."; read zpos q="scale=3; $zpos" p=0.3 #... (7 Replies)
Discussion started by: tintin72
7 Replies

6. Shell Programming and Scripting

How do i get numbers from a string?

Hi... I'm new here and i have a Q... How do i get only the number from a string? like from "rlvol11" i want to get 11 or from "lvol4" i want to get 4 what commands should i use at my script? thanx 4 the help! Eliraz. (13 Replies)
Discussion started by: eliraza6
13 Replies

7. UNIX for Dummies Questions & Answers

SCO Backup Problem (bad Sblock Magic Number)

Hi guys, First I have to say that I'm not Unix expert, I just have medium level experince in Unix scripting and some knowledge with a little of hands on experience of unix administration (Solaris only). I have my plans to move ahead in that field but this is a different story. I have a client... (0 Replies)
Discussion started by: SolarisProToBe
0 Replies
Login or Register to Ask a Question