Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How to use cat grep and cut together? Post 303044552 by synack on Wednesday 26th of February 2020 09:39:54 AM
Old 02-26-2020
How to use cat grep and cut together?

Hello,

I try to

Code:
#!/bin/bash

for ip in $(seq 1 255  );do
    host 10.11.1.$ip >> nameserver2.txt
done

I'm trying to clean up a file I created with this little batch script.

I have more results with names of servers found and not found.
Host 1.1.11.10.in-addr.arpa. not found: 3 (NXDOMAIN)
Host 2.1.11.10.in-addr.arpa. not found: 3 (NXDOMAIN)

I'm doing a nameserver2.txt grep | grep name which displays only existing servers. Except that I have too much information on each line
5.1.11.10.in-addr.arpa domain name pointer serv1.domain.com
6.1.11.10.in-addr.arpa domain name pointer serv2.domain.com


I would like to have only the 1st character each line (so the last of each IP and the name of the server
I'm making a

Code:
cat nameserver2.txt | grep name | cut -d. -f1

but in this case I only have information on two so in the end I made this order:

Code:
cat nameserver.txt | grep name | cut -d. -f1.6 | cut -d '' -f1.5

which therefore results:

5.arpa srv1
6.arpa srv2

I can't delete .arpa.

How can I do ?
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

cat and grep not working

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)
Discussion started by: jphess
3 Replies

2. UNIX for Dummies Questions & Answers

cat, grep and tee to a local file

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)
Discussion started by: shantanuo
7 Replies

3. Shell Programming and Scripting

cat or cut to delimit csv?

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)
Discussion started by: newtony
3 Replies

4. Shell Programming and Scripting

cat /etc/passwd and grep -v on /etc/shells

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)
Discussion started by: itik
4 Replies

5. Shell Programming and Scripting

cat -n and grep

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)
Discussion started by: kapu
3 Replies

6. Shell Programming and Scripting

grep or cat using sed

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)
Discussion started by: ski
3 Replies

7. Slackware

How should I cut this line using cut and grep?

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)
Discussion started by: garfish
1 Replies

8. UNIX for Dummies Questions & Answers

Grep and cat combined

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)
Discussion started by: biopsy
6 Replies

9. Shell Programming and Scripting

Replace cat and grep with <

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)
Discussion started by: nimafire
5 Replies

10. UNIX for Dummies Questions & Answers

Grep or cat The Whole Directory PROBLEMS :(

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
named(8)						      System Manager's Manual							  named(8)

Name
       named - Internet name domain server daemon

Syntax
       /usr/etc/named [ -d level# ] [ -p port# ] [ -b bootfile ][ -n ][ -a type.version ]

Description
       The daemon is the Internet domain name server for the BIND/Hesiod service.  Without any arguments, reads the default boot file and any ini-
       tial data from the BIND/Hesiod data base files.	then listens for queries.

       The boot file specifies where the BIND/Hesiod server is to get its initial data.  See the Example section.

       The master data files consist of entries of the following form:
       $include file
       $origin domain
       domain ttl addr-class entry-type resource-record-data
       The entry is useful for separating data into separate files.  The entry is useful for placing more than one domain in a data file.  It  can
       also be used to set the reverse network number origin.  The fields are:

       file	    This is the name of the file to be included.

       domain	    This  is  the  domain  name.  An at sign (@) signifies the current origin.	A name refers to the standard domain name.  If the
		    domain name does not end with a period, the current origin is appended to the domain.  A domain name ending with a	period	is
		    the complete BIND domain name (fully qualified) and thus does not get an extension appended to it.

       ttl	    This  field is an optional integer specifying the time to live.  If no time to live is specified, the default is obtained from
		    the SOA entry.

       addr-class   This field is the object class type.  There are three classes:

		    IN	       Objects connected to the DARPA Internet

		    HS	       Hesiod naming service data

		    ANY        All classes

       entry-type   The most common entries for this field are listed below.  The field, however, must correspond with the entry type:

		    A	       Host address

		    CNAME      Canonical name for an alias

		    HINFO      Host information

		    MX	       Mail exchanger

		    NS	       Authoritative name server

		    PTR        Domain name pointer

		    SOA        Start of a zone of authority

		    TXT        Hesiod text

		    WKS        Well-known service description

       The following signals have the specified effect when sent to the server process using the command:

       SIGXFSZ	    Causes the server to reload only the databases that have changed.

       SIGHUP	    Causes the server to read and reload database.

       SIGINT	    Dumps the current data base and cache to

       SIGIOT	    Dumps statistics to

       SIGUSR1	    Turns on debugging.  Each time the SIGUSR1 signal is issued, the debug level increments  by  one.	Debugging  information	is
		    dumped to

       SIGUSR2	    Turns off debugging.

Options
       -b bootfile  Names of the boot file.  If no boot file is specified, the default is

       -d level#    Prints  debugging  information.   A number after the -d option determines the level of messages printed.  It is a good idea to
		    run the daemon with the -d option in the background.

       -p port#     Specifies the port number.	The default is the standard port number listed in the file.

       -n	    Runs in network safe mode.	All HS class queries sent over the network are authenticated.  Non-authenticated  queries  for	HS
		    information from hosts other than local host are not answered.  Non-authenticated requests for zone transfers are ignored.

       -a type.version
		    Specifies  the  default authentication type.  When authenticated queries are formed, needs to know what type of authentication
		    to use.  The type parameter specifies the form of authentication.  The version parameter specifies the version of the type	to
		    use.  The supported forms of authentication are:

		    type      Kerberos

		    version   One

Examples
       The following is an example of a boot file:
       ;
       ;     boot file for name server
       ;
       ; type	  domain		 source file or host
       ;
       primary	  cities.us		 hosts.db
       ;
       primary	  2.10.in-addr.arpa	 hosts.rev
       ;
       primary	  0.0.127.in-addr.arpa	 named.local
       ;
       secondary  cc.cities.us		 10.2.0.78 128.32.0.10
       ;
       ; load the cache data last
       cache	   .			 named.ca
       Entries	beginning with a semicolon are comment lines.  In this example, the first line that is not a comment specifies that this system is
       the primary authoritative BIND server for the domain This line also specifies that the file contains authoritative  data  for  the  domain.
       Domain names in the file are relative to the origin, such as in the preceding example.

       The second and third non-comment entries (beginning with show the domain in reverse order.  This allows address to name mapping.

       The  fourth  non-comment line specifies that all authoritative data under is to be transferred from the primary master server at IP address
       to the secondary server.  If the transfer fails, the secondary server will then try the master server at address There can be up to  10	IP
       addresses listed.

       The  cache entry specifies that the data in is to be placed in the cache.  This would include well known data such as the locations of root
       domain servers.

Files
       Name server configuration boot file

       Process ID number

       Debug output

       Dump of the BIND server's cache

See Also
       kill(1), signal(3c), resolver(3), hesiod.conf(5), resolv.conf(5)
       Guide to the BIND/Hesiod Service

																	  named(8)
All times are GMT -4. The time now is 05:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy