05-05-2009
You could also use grep,nawk and tr commands ... Assumptions here are you want only IB4 in above example ...
$ vi output.ksh
#!/usr/bin/ksh
i=`grep -n "FAULT CODES CLASS" EXAMPLE.txt | cut -f 1 -d ":"`
j=`expr $i + 1`
nawk "NR==$i || NR==$j" EXAMPLE.txt > EXAMPLE1.txt
tr -d '\n\' < EXAMPLE1.txt | cut -f 4 -d " "
$ ./output.ksh
1B4
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
I have a .txt file
Sample:
=====================
NEXT HOST
=====================
AEADBAS001
ip access-list extended BLA_Incoming_Filter
ip access-list extended BLA_Outgoing_Filter
access-list 1 permit xxxxxxxxxxxxxx
access-list 2 permit xxxxxxxxxxxxxx
=====================... (4 Replies)
Discussion started by: I-1
4 Replies
2. Shell Programming and Scripting
In my script I read a input file and search all the files in a directory and it's sub-directories for that string using:
find . -type f -print | xargs grep $var1
This just displays all the lines the string was found on. Too much data.
What I need is to store in a file one time those... (17 Replies)
Discussion started by: John Rihn
17 Replies
3. Shell Programming and Scripting
Hi All: I'm using sed to replace one line in a configuration file. After replacing that line I would like to display to screen that line plus 10 lines above and below the line that was changed... How would I go about doing that??
Here is my search and replace string....
sed -e... (2 Replies)
Discussion started by: jimmyc
2 Replies
4. UNIX for Dummies Questions & Answers
Hi i would like to search for a pattern and then prints the 2 lines before the line where the pattern is found.
I would also like to apply this in compressed files.
Please help me in this. (8 Replies)
Discussion started by: khestoi
8 Replies
5. Shell Programming and Scripting
Dear all
I had input file as mention below. From that i want op as given below. Kindly let me knw possible ways.
Regards
Jaydeep
CONNECTED bscaaa
<rxmfp:mo=RXOTX-46-5 ;
RADIO X-CEIVER ADMINISTRATION
MANAGED OBJECT FAULT INFORMATION
MO BTSSWVER
RXOTX-46-5 ERA-G04-R11-V01
... (5 Replies)
Discussion started by: jaydeep_sadaria
5 Replies
6. Shell Programming and Scripting
Dear All
I had below mention requirement. Kindly sugguest me possible ways.
Thanks
Regards
Jaydeep
IN PUT FILE:
CELL BROADCAST SHORT MESSAGE SERVICE
MESSAGE DATA
ID CODE GS UPDATE MODE LANG MCO MCL NUMPAGES
50 1000 0 13 MML 1 1
TEXT PAGE
*999*1# SONGS4U@30/M- 1 (3 Replies)
Discussion started by: jaydeep_sadaria
3 Replies
7. Shell Programming and Scripting
Hi I have search everywhere for this but I haven't got any result. so here is my question?
I am trying to ask user to enter a name and then searching that name from a file and from a specific column. If user enter something, it should only displaying that name from that specific column and If the... (3 Replies)
Discussion started by: sillyha
3 Replies
8. Shell Programming and Scripting
I like "ls -ltr".
I would like to search for a file in a large directory recursively and and display all the candidates in reverse order.
/usr/bin/find . -name \*.txt
This works.
How do I display the date and sort the file names by the date in reverse order for the entire directory... (1 Reply)
Discussion started by: siegfried
1 Replies
9. UNIX for Beginners Questions & Answers
I want to search a small string in a large string and find the locations of the string. For this I used grep "string" -ob <file name where the large string is stored>. Now this gives me the locations of that string. Now how do I store these locations in a text file.
Please use CODE tags as... (7 Replies)
Discussion started by: ANKIT ROY
7 Replies
10. Shell Programming and Scripting
I have a log file which contains information like below (more than 200 ERROR sets).
Here I want to find first .c file and function after "ERROR: AddressSanitizer" line.
If you see here after "ERROR:" line first
file - asfrecohandling.c
function - ASFPotRecoHandling_Create_RecPaxSrvcComp
... (6 Replies)
Discussion started by: pushpabuzz
6 Replies
LEARN ABOUT CENTOS
findcon
findcon(1) General Commands Manual findcon(1)
NAME
findcon - SELinux file context search tool
SYNOPSIS
findcon FCLIST [OPTIONS] [EXPRESSION]
DESCRIPTION
findcon allows the user to search for files with a specified context. Results can be filtered by object class as described below.
FCLIST
The findcon tool operates upon a file context list source. There are three valid file context lists.
directory
If FCLIST is a name of a directory then begin the search at that directory and recurse within it. Be sure there are no circular
mounts within it.
file_contexts
If FCLIST is the name of a file_contexts file (e.g., /etc/selinux/strict/contexts/files/file_contexts) then open that file and find
matching entries.
database
If FCLIST is the name of a database as created by a previous run of indexcon or apol then open the database and execute queries into
it.
EXPRESSION
The following options allow the user to specify which files to print. A file must meet all specified criteria. If no expression is pro-
vided, all files are printed.
-t TYPE, --type=TYPE
Search for files with a context containing the type TYPE.
-u USER, --user=USER
Search for files with a context containing the user USER.
-r ROLE, --role=ROLE
Search for files with a context containing the role ROLE.
-m RANGE, --mls-range=RANGE
Search for files with a context with the MLS range of RANGE. Note that findcon ignores the SELinux translation library, if present.
In addition, this flag is ignored if the FCLIST has no MLS information.
--context=CONTEXT
Search for files matching this partial context. This flag overrides -t, -u, -r, and -m.
-p PATH, --path=PATH
Search for files which include PATH.
-c CLASS, --class=CLASS
Search only files of object class CLASS.
OPTIONS
The following additional options are available.
-R, --regex
Search using regular expressions instead of exact string matching. This option does not affect the --class flag.
-h, --help
Print help information and exit.
-V, --version
Print version information and exit.
PARTIAL CONTEXT
The --context flag specifies a partial context, which is a a colon separated list of user, role, and type. If the system supports MLS, the
context may have a fourth field that gives the range. If a field is not specified or is the literal asterisk, then the query will always
match the field.
OBJECT CLASSES
Valid object class strings are
block, char, dir, fifo, file, link, or sock.
NOTE
The findcon utility always operates on "raw" SELinux file contexts. If the system has an installed translation library (i.e., libsetrans),
those translations are ignored in favor of reading the original contexts from the filesystem (if FCFILE is a directory).
EXAMPLES
findcon .
Find every context in the current directory and all of its subdirectories.
findcon -u user_u .
Find every context whose user is user_u in the current directory and all subdirectories.
findcon -u system_u -t bin_t file_contexts
Find entries user system_u and type bin_t within a file_contexts file, assuming that file_contexts is a file contexts file.
findcon --context=system_u::bin_t file_contexts
This is equivalent to the previous example.
findcon --context=system_u:*:bin_t:* file_contexts
This is also equivalent to the above example.
AUTHOR
This manual page was written by Jeremy A. Mowery <jmowery@tresys.com>.
COPYRIGHT
Copyright(C) 2003-2007 Tresys Technology, LLC
BUGS
Please report bugs via an email to setools-bugs@tresys.com.
SEE ALSO
replcon(1), indexcon(1)
findcon(1)