02-27-2009
proper syntax of grep command
I'm learning UNIX on my mac (BSD), using a manual. I'm trying to figure out the grep command, and am getting something wrong. I've opened one of my files in NeoOffice and am looking for a string, the phrase 'I am writing.' I've been to some sites to get the proper syntax, and from what I can see the proper syntax is:
grep "I am writing" [file name]
A lot of times I get the message that no such file or directory exists, even when I think I've entered all the information. When that doesn't happen, the cursor just blinks, with no display of the string I'm looking for. Can someone tell me what I'm missing? Granted, the book i'm using is the OS X missing manual by david pogue, and it's only a few paragraphs on the command, so I may not be comprehending something. Please, if you could write out the proper syntax (including any slashes, dots, etc.) so I can compare it to what I'm doing.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I need to extract information from a 4 GB file based on the following conditions:
1) Check for the presence of a set of account numbers
Each account number is present along with other information within
a PAGESTART and PAGEEND.
The file looks like this:
PAGESTART
ACCOUNT NO 123... (6 Replies)
Discussion started by: kthri
6 Replies
2. Shell Programming and Scripting
I wanna grep for a pattern logs 1 2 & 3 within a folder containing 100 logs
grep "test" /folder/log1 /folder/log2 /folder/log3
The above command will work fine
but is there any command like
grep "test" /folder/log1, log2, log3 or something similar (4 Replies)
Discussion started by: roshanjain2
4 Replies
3. Shell Programming and Scripting
Net::SSH::Perl ...... how to print the output in a proper format
my $cmd = "ls -l";
my $ssh = Net::SSH::Perl->new($host);
$ssh->login($user, $pass);
my($stdout, $stderr, $exit) = $ssh->cmd("$cmd");
print $stdout;
the script works fine, but i am unable to see the output... (2 Replies)
Discussion started by: gsprasanna
2 Replies
4. UNIX for Dummies Questions & Answers
Hello,
I'm working on unix with grep (GNU grep) 2.5.1. I'm going through some of the newer regex syntax using Regular Expression Reference - Advanced Syntax a guide.
ls -aLl /bin | grep "\(x\)"
Which works, just highlights 'x' where ever, when ever.
I'm trying to to get (?:) to work but... (4 Replies)
Discussion started by: MykC
4 Replies
5. UNIX for Dummies Questions & Answers
I'm new to Unix, and just had a quick question.
I'm writing a bash script, and I was wondering what proper programming etiquette was for piping. How many pipes is too many pipes?
OLDEST=$(find . -maxdepth 1 -type d -newermt 2012-07-01 ! -newermt
2012-07-30 | xargs ls -1td | tail -2)
echo... (1 Reply)
Discussion started by: jrymer
1 Replies
6. Shell Programming and Scripting
Hi Guys,
I need to grep below data in this format
backup_id
creation
expiration
policy
sched_label
backup_id = picoserver38_1212077050, version = 2
creation = 05/29/2008 18:04:10 (1212077050)
expiration = 06/29/2008 18:04:10 (1214755450)
retention_level = 3, fragment = 2, file_num = 1... (14 Replies)
Discussion started by: manalisharmabe
14 Replies
7. Shell Programming and Scripting
What is the proper way to run two commands together?
For example, in the below I would like run a command in bold then pipe that output to awk to re-format it. Thank you :).
bedtools nuc -fi /home/cmccabe/Desktop/bed/hg19.fa -bed /home/cmccabe/Desktop/bed/xgen_baits.bed >... (3 Replies)
Discussion started by: cmccabe
3 Replies
8. Shell Programming and Scripting
Dear Team
/app/Appln/logs/
echo Session used server are 'grep -i pid|grep -i session | cut -d'.' -f1 | awk '{print $9}' | sort | uniq'
Output -
lxserver01
lxserver02
lxserver03
When I grep session pid in logs server details I can see above distinct server details but I... (6 Replies)
Discussion started by: skp
6 Replies
9. Shell Programming and Scripting
I am trying to write a korn shell script (Z.ksh) that will execute three other korn shell scripts within it. The three korn shell scripts (A.ksh,B.ksh,C.ksh) each execute a series of .sas programs. A.ksh, B.ksh, and C.ksh must each wait until the last .sas program within them executes and finishes... (2 Replies)
Discussion started by: imoore
2 Replies
10. UNIX for Beginners Questions & Answers
I have a question to this command
find . -type f -name ".*txt" -exec grep "text" {}\.
The find command will locate a file name with the extension of txt once per round and find the word "text" in the content of the file or the find command will locate all the file names with the extension of... (2 Replies)
Discussion started by: TestKing
2 Replies
LEARN ABOUT OPENSOLARIS
tnchkdb
tnchkdb(1M) System Administration Commands tnchkdb(1M)
NAME
tnchkdb - check file syntax of trusted network databases
SYNOPSIS
/usr/sbin/tnchkdb [-h path] [-t path] [-z path]
DESCRIPTION
tnchkdb checks the syntax of the tnrhtp, tnrhdb, and tnzonecfg databases. By default, the path for each file is:
o /etc/security/tsol/tnrhtp
o /etc/security/tsol/tnrhdb
o /etc/security/tsol/tnzonecfg
You can specify an alternate path for any or all of the files by specifying that path on the command line by using the -h (tnrhdb), -t
(tnrhtp) and -z (tnzonecfg) options. The options are useful when testing a set of modified files before installing the files as new system
databases.
All three database files are checked for integrity. tnchkdb returns an exit status of 0 if all of the files are syntactically and, to the
extent possible, semantically correct. If one or more files have errors, then an exit status of 1 is returned. If there are command line
problems, such as an unreadable file, an exit status of 2 is returned. Errors are written to standard error.
To avoid cascading errors, when there are errors in tnrhtp, the template names in tnrhdb are not validated.
tnchkdb can be run at any label, but the standard /etc/security/tsol files are visible only in the global zone.
OPTIONS
-h [ path ] Check path for proper tnrhdb syntax. If path is not specified, then check /etc/security/tsol/tnrhdb.
-t [ path ] Check path for proper tnrhtp syntax. If path is not specified, then check /etc/security/tsol/tnrhtp.
-z [ path ] Check path for proper tnzonecfg syntax. If path is not specified, then check /etc/security/tsol/tnzonecfg.
EXAMPLES
Example 1 Sample Error Message
The tnchkdb command checks for CIPSO errors. In this example, the admin_low template has an incorrect value of ADMIN_HIGH for its default
label.
# tnchkdb
checking /etc/security/tsol/tnrhtp ...
tnchkdb: def_label classification 7fff is invalid for cipso labels:
line 14 entry admin_low
tnchkdb: def_label compartments 241-256 must be zero for cipso labels:
line 14 entry admin_low
checking /etc/security/tsol/tnrhdb ...
checking /etc/security/tsol/tnzonecfg ...
FILES
/etc/security/tsol/tnrhdb
Trusted network remote-host database
/etc/security/tsol/tnrhtp
Trusted network remote-host templates
/etc/security/tsol/tnzonecfg
Trusted zone configuration database
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWtsu |
+-----------------------------+-----------------------------+
|Interface Stability |See below. |
+-----------------------------+-----------------------------+
The command line is Committed. The output is Uncommitted.
SEE ALSO
tnd(1M), tnctl(1M), attributes(5)
How to Check the Syntax of Trusted Network Databases in Solaris Trusted Extensions Administrator's Procedures
NOTES
The functionality described on this manual page is available only if the system is configured with Trusted Extensions.
It is possible to have inconsistent but valid configurations of tnrhtp and tnrhdb when LDAP is used to supply missing templates.
SunOS 5.11 20 Jul 2007 tnchkdb(1M)