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
CSV1(5) 							 MaraDNS reference							   CSV1(5)

NAME
csv1 - Format of the csv1 zone file that MaraDNS uses SPECIAL NOTE
The csv1 zone file format is supported primarily for MaraDNS users who already have zone files in the csv1 format. MaraDNS now supports a csv2 zone file format. Note that the csv1 zone file format will continue to function as long as I am MaraDNS' maintainer. SPECIAL CHARACTERS
| This delimits fields # This signifies a comment. Lines starting with this are ignored, otherwise it has no significance % This, in domain names, signifies that the rest of the domain name should be the name of this zone * This is translated to mean "any host name that otherwise does not resolve". It must be at the beginning of a domain name. This is used as an escape character, either to escape octal values such as '45' for %, or to escape the '%' character so it has no special meaning, or to escape the backslash character. NOTES ON PROCESSING
All domain-name labels are converted to their lower-case equivalents before processing is done. This is because domain-name literals in the database with one or more upper-case letters in them are case-sensitive. This is my way to resolve RFC1035 schizophrenic desire to both allow binary domain labels, and its desire to be case-insensitive. The file must first have a SOA record, followed by one or more NS records, followed by other records. The initial NS and SOA records must be RR for this zone. NS records after any non-NS record must be part of another zone. The resolution algorithm will not break if non-CNAME records share records with a CNAME record, but this is not a good idea to do. RR FORMAT
A domain name is a one-letter designation of its type, followed by the domain name separated by dots, ending with either a % or a trailing dot. If the domain name does not end with a % or trailing dot, an error is returned. SUPPORTED RR TYPES
MaraDNS only supports the following types of resource records (RRs) in csv1 files. More resource records types are supported in csv2 zone files; see csv2(5) for details. Letter Type RFC1035 section 3.2.2 value A A 1 N NS 2 C CNAME 5 S SOA 6 P PTR 12 @ MX 15 T TXT 16 U any determined in third field of line FORMAT OF SUPPORTED RR TYPES
Here are the formats, shown by letter name: A: Has three fields field one: the domain name field two: the ttl for the name in seconds field three: the ip address, in dotted decimal notation Example: Ahost.example.com.|7200|10.1.2.3 A records are described with grueling detail in RFC1035. In short, an A record is an IP address for a given host name. N: Has three fields field one: the domain name of the record field two: the ttl for the name in seconds field three: the domain name this NS points to. Example: Nexample.com.|86400|ns.example.com. NS (N here) records are described in RFC1035 C: Has three fields field one: the domain name of the record field two: the ttl for the name in seconds field three: the domain this CNAME record points to Example: Calias.example.org.|3200|realname.example.org. CNAME (which C is short for) records are described in RFC1035 S: Has nine fields field one: the domain name of the record field two: the TTL of the record field three: the origin of the domain. In other words, the name of the primary name server for the domain. field four: the email address for this domain (in the RFC822, not BIND format) field five: the serial for the domain field six: the refresh (how often to see updates) for the domain field seven: the retry (how often to try when down) for the domain field eight: the expire (how long before the slave gives up) for the domain field nine: the minimum (and default) TTL for the domain Example: Sexample.net.|86400|%|hostmaster@%|19771108|7200|3600|604800|1800 SOA (S here) records are described in RFC1035 P: has three fields field one: the IP we wish to point to (in in-addr.arpa form) field two: the ttl for the name in seconds field three: the FQDN for the IP in question Example: P3.2.1.10.in-addr.arpa.|86400|ns.example.com. PTR (P here) records, which are used for reverse DNS lookups, are described in RFC1035. Note that one needs control of the appropriate in- addr.arpa subdomain to make PTR records visible on the internet at large. @: has four fields field one: The host that people send email to field two: the ttl for this record field three: The preference for this MX host field four: The name of this MX host Example: @example.com.|86400|10|mail.example.com. MX (@ here) records are described in RFC1035 T: has three fields field one: The host someone wants to get additional information about field two: the ttl for this record field three: The desired text. Any data becomes the record up until a new line is reached. The new line is not part of the TXT record Example: Texample.com.|86400|Example.com: Buy example products online TXT (T here) records are described in RFC1035 U: has four fields field one: The host someone wants a data type normally unsupported by MaraDNS for field two: the ttl for this record field three: The numeric code for this data type (33 for SRV, etc.) field four: The raw binary data for this data type Example: Uexample.com.|3600|40|100102Kitchen sink data The above example is a "Kitchen Sink" RR (see draft-ietf-dnsind-kitchen-sink-02.txt) with a "meaning" of 8, a "coding" of 1, a "subcoding" of 2, and a data string of "Kitchen sink data". Since this particular data type is not formalized in a RFC at this time, the most appropriate method of storing this data is by using the catch-all "unsupported" syntax. EXAMPLE CSV1 ZONE FILE # Example CSV1 zone file # This is what is known as a SOA record. All zone files need to have one # of these S%|86400|%|hostmaster@%|19771108|7200|3600|604800|1800 # These are known as authoritative NS records. All zone files need # one or more of these N%|86400|ns1.% N%|86400|ns2.% # Some IP addresses Ans1.%|86400|10.0.0.1 Ans2.%|86400|192.168.0.1 A%|86400|10.1.2.3 Amx.%|86400|10.1.2.4 # An 'IN MX' record @%|86400|10|mx.% LEGAL DISCLAIMER
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. AUTHOR
Sam Trenholme http://www.samiam.org/ MARADNS
January 2002 CSV1(5)
All times are GMT -4. The time now is 08:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy