There's NO string like "reached" in your samples, nor semicolons. Those don't show up in my host calls, either. Replace ! /^Host/ with /domain/ or /name/ or /pointer/. If that doesn't help, show your input data.
cat is by no means needed in any of your attempts as both grep and cut can open files by themselves, or you can redirect stdin for them. grepping the first number is quite easy, like
, but extracting the remote hostname not so as you don't know what the FQDN looks like. The nearest I get is
Yes you are right. it's my fault. There somes lines that i didn't see in the original file, like ";; connection timed out; no servers could be reached"
I am trying to cat a file and then grep that file for a number. I can do it fine on other files but this particular file will not do anything. I tried running it on an older file from the same device but it is just not working. The file is nothing more than a flat file on a unix box. Here is just a... (3 Replies)
Hi,
This is what I am trying to do.
1) connect to 3 remote servers from my local machine
serverA serverB serverC
2) read error file from each server
cat /var/lib/mysql/mydb.err
3) grep for lines displaying "yesterday" date
grep "`date +%y%m%d' '-d\"1 day ago\"`"
4) Append those lines to a... (7 Replies)
Hi,
Im a pretty large noob to linux/perl etc and im trying to use mysql slurp to take a delimited file and import it into mysql using stdin (in the hope its faster)
mysqlslurp - slurp <STDIN> into a MySQL table - search.cpan.org
Christopher Brown / MySQL-Slurp - search.cpan.org
Using... (3 Replies)
Hi All,
I'd like to do this
cat /etc/passwd
and grep -v on the /etc/shells list
I'd like to find all shell that doesn't exist on the /etc/passwd.
Is there an easy way without doing a egrep -v "/bin/sh|/bin/bash................"?
How do I use a file /etc/shells as my list for... (4 Replies)
I am not sure if using cat -n is the most efficient way to split a file into multiple files, one file per line in the source file.
I thought using cat -n would make it easy to process the file because it produces an output that numbers each line that I could then grep for with the regex "^ *$i".... (3 Replies)
Is there a way using grep or cat a file to create a new file based on whether the first 9 positions of each record is less than 399999999?
This is a fixed file format. (3 Replies)
not sure how to do it. wan't to delete it using cut and grep ince i would use it in the shell.
but how must the command be?
grep "64.233.181.103 wwwGoogle.com" /etc/hosts | cut -d
the delimeter is just a space. can you help meplease. :D (1 Reply)
Hello,
i need to search one word (snp1) from many files and copy the content of the columns of this word in new file.
example:
file 1:
SNP BP CHR P
snp1 1 3 0.01
snp2 2 2 0.05
.
.
file 2:
SNP BP CHR P
snp1 1 3 0.06
snp2 2 2 0.3
output... (6 Replies)
Hello
someone told me to use
OS=`awk '{print int($3)}' < /etc/redhat-release`
instead of
OS=cat /etc/redhat-release | `awk '{print int($3)}'`
any idea for the reason ? (5 Replies)
Hi Guys
This is my first post so I am not sure how things go here. I'm sorry if I'm breaking the rule or something. Feel free to correct me about that :)
So as I was saying...
I'd been trying to grep this folder containing 900,000 txt files but seems no luck. I get either "No such file... (6 Replies)
Discussion started by: Nexeu
6 Replies
LEARN ABOUT SUNOS
cut
cut(1) User Commands cut(1)NAME
cut - cut out selected fields of each line of a file
SYNOPSIS
cut -b list [-n] [file...]
cut -c list [file...]
cut -f list [-d delim] [-s] [file...]
DESCRIPTION
Use the cut utility to cut out columns from a table or fields from each line of a file; in data base parlance, it implements the projection
of a relation. The fields as specified by list can be fixed length, that is, character positions as on a punched card (-c option) or the
length can vary from line to line and be marked with a field delimiter character like <TAB> (-f option). cut can be used as a filter.
Either the -b, -c, or -f option must be specified.
Use grep(1) to make horizontal ``cuts'' (by context) through a file, or paste(1) to put files together column-wise (that is, horizontally).
To reorder columns in a table, use cut and paste.
OPTIONS
The following options are supported:
list A comma-separated or blank-character-separated list of integer field numbers (in increasing order), with optional - to
indicate ranges (for instance, 1,4,7; 1-3,8; -5,10 (short for 1-5,10); or 3- (short for third through last field)).
-b list The list following -b specifies byte positions (for instance, -b1-72 would pass the first 72 bytes of each line). When -b
and -n are used together, list is adjusted so that no multi-byte character is split.
-c list The list following -c specifies character positions (for instance, -c1-72 would pass the first 72 characters of each line).
-d delim The character following -d is the field delimiter (-f option only). Default is tab. Space or other characters with special
meaning to the shell must be quoted. delim can be a multi-byte character.
-f list The list following -f is a list of fields assumed to be separated in the file by a delimiter character (see -d ); for
instance, -f1,7 copies the first and seventh field only. Lines with no field delimiters will be passed through intact (use-
ful for table subheadings), unless -s is specified.
-n Do not split characters. When -b list and -n are used together, list is adjusted so that no multi-byte character is split.
-s Suppresses lines with no delimiter characters in case of -f option. Unless specified, lines with no delimiters will be
passed through untouched.
OPERANDS
The following operands are supported:
file A path name of an input file. If no file operands are specified, or if a file operand is -, the standard input will be
used.
USAGE
See largefile(5) for the description of the behavior of cut when encountering files greater than or equal to 2 Gbyte (2**31 bytes).
EXAMPLES
Example 1: Mapping user IDs
A mapping of user IDs to names follows:
example% cut -d: -f1,5 /etc/passwd
Example 2: Setting current login name
To set name to current login name:
example$ name=`who am i | cut -f1 -d' '`
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of cut: LANG, LC_ALL, LC_CTYPE, LC_MES-
SAGES, and NLSPATH.
EXIT STATUS
The following exit values are returned:
0 All input files were output successfully.
>0 An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
|CSI |Enabled |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
SEE ALSO grep(1), paste(1), attributes(5), environ(5), largefile(5), standards(5)DIAGNOSTICS
cut: -n may only be used with -b
cut: -d may only be used with -f
cut: -s may only be used with -f
cut: cannot open <file> Either file cannot be read or does not exist. If multiple files are present, processing continues.
cut: no delimiter specified Missing delim on -d option.
cut: invalid delimiter
cut: no list specified Missing list on -b, -c, or -f option.
cut: invalid range specifier
cut: too many ranges specified
cut: range must be increasing
cut: invalid character in range
cut: internal error processing input
cut: invalid multibyte character
cut: unable to allocate enough memory
SunOS 5.10 29 Apr 1999 cut(1)