Sponsored Content
Top Forums Shell Programming and Scripting To test whether a field contains string value Post 303003904 by Sang on Friday 22nd of September 2017 11:47:29 AM
Old 09-22-2017
Pipe delimter.Tried to get that specific field value
Code:
cut -d "|" -f 26 filename | head

From the above I found 10 values with all numbers . File is huge . With Grep I have to specify all characters But I don't that way .I just want a command to check whether characters are available in this field . Based on this I will decide it's datatype.

Last edited by MadeInGermany; 09-22-2017 at 01:01 PM.. Reason: added code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

string test?

hey guys- what is the syntax for a string test to verify that a user has entered a 6 digit numeric? Thanks for your help in advance! Todd (9 Replies)
Discussion started by: hedrict
9 Replies

2. UNIX for Dummies Questions & Answers

test a string...

Hi! I'm using echo $string | grep "" -c to test in a script if a string is a number and it seems to work. But how can i find, for example, if a string is a four figures number ? Thanks to all! (2 Replies)
Discussion started by: Kaminski
2 Replies

3. Shell Programming and Scripting

Test on string containing spacewhile test 1 -eq 1 do read a $a if test $a = quitC then break fi d

This is the code: while test 1 -eq 1 do read a $a if test $a = stop then break fi done I read a command on every loop an execute it. I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test. For example echo hello. Now the... (1 Reply)
Discussion started by: Max89
1 Replies

4. Shell Programming and Scripting

How to check weather a string is like test* or test* ot *test* in if condition

How to check weather a string is like test* or test* ot *test* in if condition (5 Replies)
Discussion started by: johnjerome
5 Replies

5. Shell Programming and Scripting

string test in IF statement

How do I test multiple words in a string test like below: if ] then print "You entered $TBS name.\n" else print "You entered an incorrect response.\n" fi This test does not work. I have tried different syntax versions. How does this work? And is there a better way to do it? ... (10 Replies)
Discussion started by: djehresmann
10 Replies

6. Shell Programming and Scripting

Awk Search text string in field, not all in field.

Hello, I am using awk to match text in a tab separated field and am able to do so when matching the exact word. My problem is that I would like to match any sequence of text in the tab-separated field without having to match it all. Any help will be appreciated. Please see the code below. awk... (3 Replies)
Discussion started by: rocket_dog
3 Replies

7. Shell Programming and Scripting

string test

How do I use bash to test if a line begins with a random number of spaces followed by a letter? (1 Reply)
Discussion started by: locoroco
1 Replies

8. Shell Programming and Scripting

test for a blank string

Hi guys I am performing a simple test for a blank string with the following code: if ] ]] ; then echo "Blanks are NOT a valid input " return 1 fi The above fails giving a syntax error message: syntax error at line 142 : `=~' unexpected I am in ksh88 is there... (2 Replies)
Discussion started by: aoussenko
2 Replies

9. Linux

How do I format a Date field of a .CSV file with multiple commas in a string field?

I have a .CSV file (file.csv) whose data are all enclosed in double quotes. Sample format of the file is as below: column1,column2,column3,column4,column5,column6, column7, Column8, Column9, Column10 "12","B000QRIGJ4","4432","string with quotes, and with a comma, and colon: in... (3 Replies)
Discussion started by: dhruuv369
3 Replies

10. UNIX for Beginners Questions & Answers

awk Associative Array and/or Referring to Field by String (Nonconstant String Value)

I will start with an example of what I'm trying to do and then describe how I am approaching the issue. File PS028,005 Lexeme HRS # M # PhraseType 1(1:1) 7(7) PhraseLab 501 503 ClauseType ZYq0 PS028,005 Lexeme W # L> # BNH # M #... (17 Replies)
Discussion started by: jvoot
17 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)
All times are GMT -4. The time now is 07:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy