Awk: To search for 02/24/2005 in a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Awk: To search for 02/24/2005 in a file
# 1  
Old 02-26-2005
Awk: To search for 02/24/2005 in a file

Hi

I am writing a shell script in which I have to search all records
which are dated 02/24/2005. The file consists of date in mm/dd/yyy format and corresponding job name.

When I tried to use awk /"$1"/ filelist where $1 is input date e.g 02/24/2005 , it gives an error .

I want to search 02/24/2005 as a string and extract record based on this search pattern.

Kindly reply as soon as possible

Thanks
# 2  
Old 02-26-2005
Code:
 awk '/02\/24\/2005/ { print $0 }' file1

# 3  
Old 02-26-2005
the easy way is use grep for this pattern.

Code:
a="02/24/2005"
grep $a file1


Using awk ....

Code:
export a="02/24/2005"
awk -vb=$a '{ if ( $0 ~ b ) { print $0 } } ' file1


Last edited by bhargav; 02-26-2005 at 04:51 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk search patterns from file in another

I would like to grep for aaa and bbb and ccc from one line in file1.txt in any order on a line on file2.txt file1.txt aaa bbb ccc ddd fff ggg hhh ddd jjj jjj cccfile2.txt aaa bbb ccc ddd fff ggg --> output whole line since it matches with aaa bbb ccc of file1.txt aaa ddd jjj hhh --> no... (1 Reply)
Discussion started by: sdf
1 Replies

2. Shell Programming and Scripting

Search and replace from file in awk using a 16 bit text file

Hello, Some time ago a helpful awk file was provided on the forum which I give below: NR==FNR{A=$0;next}{for(j in A){split(A,P,"=");for(i=1;i<=NF;i++){if($i==P){$i=P}}}}1 While it works beautifully on English and Latin characters i.e. within the ASCII range of 127, the moment a character beyond... (6 Replies)
Discussion started by: gimley
6 Replies

3. Shell Programming and Scripting

awk get search pattern from a file.

Here Is a problem I am facing with awk. Query --> I want to search for a string in a file and print next 15 lines below the matched string. 1.We do not have GNU grep so cannot use grep -A or grep -B commands. 2. Instead of passing the search pattern as a string to awk. I want the awk to... (4 Replies)
Discussion started by: togotutor
4 Replies

4. Shell Programming and Scripting

Using Awk to Search to a Certain point in File

a command like the one below will search a file from the date and time specified to the END of the log. awk "/^2011-12-26 14:37/,0" /apps/prodction.log How do i make it so that it doesn't search to the END of the log but instead stops at a specified section of the log. for instance, if i... (1 Reply)
Discussion started by: SkySmart
1 Replies

5. Shell Programming and Scripting

Search parameters on file with AWK

Hello everyone!! I need help with this please: I have a file with this content: 56977964333 730030201857822 1 2 4 56976969284 730030201412442 1 2... (3 Replies)
Discussion started by: bobbasystem
3 Replies

6. Shell Programming and Scripting

search and edit in the same file using awk

Hi, I am having a user.txt contains the name of users and passwd.txt file contains as passwd.txt $cat usr.txt root bin daemon cap $cat passwd.txt root:x:0:0:root:/root:/usr/bin/ksh bin:x:1:1:bin:/bin:/sbin/csh daemon:x:2:2:daemon:/sbin:/usr/bin/ksh adm:x:3:4:adm:/var/adm:/sbin/nologin... (4 Replies)
Discussion started by: Manabhanjan
4 Replies

7. Shell Programming and Scripting

Exporting .csv file into mysql server 2005 using script.

Hi, I have a .csv file created by a script with data in a tabular format. I need to insert all the value into mysql database which is running in a different machine. what is the command to export the .csv file into database using shell script. Thanks in advance. (3 Replies)
Discussion started by: ahamed
3 Replies

8. Shell Programming and Scripting

Using awk to when reading a file to search and output to file

Hi, I am not sure if this will work or not. I am getting a syntax error. I am reading fileA, using an acct number field trying to see if it exists in fileB and output to new file. Can anyone tell me if what I am doing will work or should I attempt it another way? Thanks. exec < "${fileA}... (4 Replies)
Discussion started by: ski
4 Replies

9. Shell Programming and Scripting

Read a file and search a value in another file create third file using AWK

Hi, I have two files with the format shown below. I need to read first field(value before comma) from file 1 and search for a record in file 2 that has the same value in the field "KEY=" and write the complete record of file 2 with corresponding field 2 of the first file in to result file. ... (11 Replies)
Discussion started by: King Kalyan
11 Replies

10. Shell Programming and Scripting

TO execute .sql 2005 query file in shell script

Hi, I know in oracle a .sql file is called by @ <path> /<filename>. But how to call in sql 2005, I am opening the sql sessionwith sqsh, is there any command to execute there a .sql file (query in sql 2005) in K shell script. (0 Replies)
Discussion started by: n2ekhil
0 Replies
Login or Register to Ask a Question