Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How to grep variable in shell script? Post 303014855 by scriptor on Thursday 22nd of March 2018 02:37:52 AM
Old 03-22-2018
Hi Andrew/Rudic,

I tried both the option suggested by you.
however I am not getting any output.

please suggest.

Code:
 
 # set -x
# cat /var/logs/File.txt.0 |grep "${d}" | head 
+ grep ' 20180322 11:56'
+ head
+ cat /var/logs/File.txt.0

Code:
 
 # set -x
# echo $d
+ echo 20180322 11:56
20180322 11:56
# fgrep "${d}" /var/logs/File.txt.0 | head 
+ head
+ fgrep ' 20180322 11:56' /var/logs/File.txt.0
#

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep results to store in a shell variable

I have the results of a grep with -n store in a shell variable ie VAR=`grep -n -e 'PATTERN' file` How ever I am missing the line breaks in the variable , How do I store the resualts of grep with many lines in to a variables. I want the varable should be the sawmway as we do the grep grep... (3 Replies)
Discussion started by: jojan
3 Replies

2. Shell Programming and Scripting

How to return a value of a variable from shell script to perl script

HI , Is there any way to return a value of variable from shell to perl script. Code: === Perl file my $diff1=system("sh diff.sh"); my $diff2=system("sh diff1.sh"); I need exit status of below commands i.e 0 and 1 respectively. Since in both the cases diff is working so system... (3 Replies)
Discussion started by: srkelect
3 Replies

3. Shell Programming and Scripting

Shell script / Grep / Awk to variable and Loop

Hi, I have a text file with data in that I wish to extract, assign to a variable and process through a loop. Kind of the process that I am after: 1: Grep the text file for the values. Currently using: cat /root/test.txt | grep TESTING= | awk -F"=" '{ a = $2 } {print a}' | sort -u ... (0 Replies)
Discussion started by: Spoonless
0 Replies

4. Shell Programming and Scripting

assign awk's variable to shell script's variable?

Dear All, we have a command output which looks like : Total 200 queues in 30000 Kbytes and we're going to get "200" and "30000" for further process. currently, i'm using : numA=echo $OUTPUT | awk '{print $2}' numB=echo $OUTPUT | awk '{print $5}' my question is : can I use just one... (4 Replies)
Discussion started by: tiger2000
4 Replies

5. Shell Programming and Scripting

How to grep sql error in shell script and exit the script?

I need help in the following script. I want to grep the sql errors insert into the error table and exit the shell script if there is any error, otherwise keep running the scripts. Here is my script #!/bin/csh -f source .orapass set user = $USER set pass = $PASS cd /opt/data/scripts echo... (2 Replies)
Discussion started by: allinshell99
2 Replies

6. Shell Programming and Scripting

Issue with passing variable to Grep in a shell script

Hi, I'm trying to check if methods specified in a class have been added to the corrosponding interface. My code below is giving me the following errors: grep: function: No such file or directory grep: import($zipfile): No such file or directory grep: function: No such file or... (1 Reply)
Discussion started by: racshot65
1 Replies

7. Shell Programming and Scripting

Unable to pass shell script variable to awk command in same shell script

I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist. diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff | awk... (2 Replies)
Discussion started by: Ashunayak
2 Replies

8. Shell Programming and Scripting

Variable not working in grep from script

Hi, If I hard code a value in the grep it works fine from script, when I use variable it doesn't work. On a seperate note, some lines (during testing) works fine from command line but not from scirpt. #!/bin/bash # Will fetch the (oldest - as ls will sort by name by default)Date in the... (7 Replies)
Discussion started by: krish.m
7 Replies

9. Shell Programming and Scripting

Shell script to pass the config file lines as variable on the respective called function on a script

I want to make a config file which contain all the paths. i want to read the config file line by line and pass as an argument on my below function. Replace all the path with reading config path line by line and pass in respective functions. how can i achieve that? Kindly guide. ... (6 Replies)
Discussion started by: sadique.manzar
6 Replies

10. UNIX for Beginners Questions & Answers

How can I assign awk's variable to shell script's variable?

I have the following script, and I want to assign the output ($10 and $5) from awk to N and L: grdinfo data.grd | awk '{print $10,$5}'| read N L output from gridinfo data.grd is: data.grd 50 100 41 82 -2796 6944 0.016 0.016 3001 2461. where N and L is suppose to be 3001 and 100. I use... (8 Replies)
Discussion started by: geomarine
8 Replies
ncab2clf(1)							   User Commands						       ncab2clf(1)

NAME
ncab2clf - convert binary log file to Common Log File format SYNOPSIS
/usr/bin/ncab2clf [-Dhv] [-i input-file] [-o output-file] [-b size] [-n number] [-s datetime] DESCRIPTION
The ncab2clf command is used to convert the log file generated by the Solaris Network Cache and Accelerator ("NCA") from binary format, to Common Log File ("CLF") format. If no input-file is specified, ncab2clf uses stdin. If no output-file is specified, the output goes to std- out. OPTIONS
-b Specifies the binary-log-file blocking in kilobytes; the default is 64 Kbyte. -D Specifies that direct I/O be disabled. -h Prints usage message. -i input-file Specifies the input file. -n number Output number CLF records. -o output-file Specifies the output file. -s datetime Skip any records before the date and time specified in datetime. You can specify the date and time in CLF format or in the format specified by the touch(1) utility. CLF format is the dominant format, so ncab2clf first analyzes datetime assuming CLF. -v Provides verbose output. EXAMPLES
Example 1: Converting a Binary File to a Common Log File Format The following example converts the binary file /var/nca/logs/nca.blf to a file /var/nca/logs/nca.clf, which is in Common Log File format. example% ncab2clf -D -i /var/nca/logs/nca.blf -o /var/nca/logs/nca.clf Example 2: Converting Multiple Log Files The following script may be used to convert multiple log files. The directory designated by "*" must only contain log files. !/bin/ksh for filename in * do ncab2clf -D < $filename > $filename.clf done Example 3: Using -s and -n on a Raw Device The following example shows how ncab2clf can be used on a raw device. If not using the -n option, the default is to convert all records from the starting location to the end of the file. The date and time specified with -s, below, is in CLF format. example% ncab2clf -s '10/Apr/2001:09:23:13' -n 100 < /dev/dsk/c2t1d0s6 EXIT STATUS
The following exit values are returned: 0 The file converted successfully >0 An error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWncau | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ SEE ALSO
nca(1), ncakmod(1), nca.if(4), ncakmod.conf(4), ncalogd.conf(4), attributes(5) System Administration Guide: IP Services NOTES
The binary log files generated by NCA can become very large. When converting these large binary files, use the -b option to the ncab2clf command to help performance. Direct I/O is a benefit to the user if the data being written does not come in as large chunks. However, if the user wishes to convert the log file in large chunks using the -b option, then direct I/O should be disabled by using the -D option. SunOS 5.10 28 Sep 2001 ncab2clf(1)
All times are GMT -4. The time now is 03:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy