You could try something like:
If you want to try this on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk, /usr/xpg6/bin/awk, or nawk.
If you have a file named makefile that contains:
the script above will produce the output:
This User Gave Thanks to Don Cragun For This Post:
Hi All,
Can someone please help me write a script for the following requirement in awk, grep, sed or perl.
Buuuu xxx bbb
Kmmmm rrr ssss uuuu
Kwwww zzzz ccc
Roooowwww eeee
Bxxxx jjjj dddd
Kuuuu eeeee nnnn
Rpppp cccc vvvv cccc
Rhhhhhhyyyy tttt
Lhhhh rrrrrssssss
Bffff mmmm iiiii
Ktttt... (5 Replies)
We have the following statement working in CGYWIN, but when we move the program to Solaris 10 it fails.
x=`echo "ABC196925XYZ" | grep -o --only-matching "\{6\}"`
How can we use AWK or SED to extract only the number from the string?
The following outputs the entire string. We only want... (5 Replies)
Dear friends
I am new to linux and was trying to split some files userwise in our linux server.
I have a data file of 156 continuous columns named ecscr final.
I want the script to redirect all the lines containing a pattern of 7 digits to separate files. I was using grep to do that,... (2 Replies)
Hello All,
I have a file which is having below type of data,
Jul 19 2011 | 123456
Jul 19 2011 | 123456
Jul 20 2011 | 123456
Jul 20 2011 | 123456
Here I wanted to grep for date pattern as below, so that it should only grep "Jul 20" OR "Jul ... (9 Replies)
I have an array containing bunch of characters. I have to check this array for specific character and if "Not Found than" use a goto statement to go to USAGE
set options = (A B C D E F)
@ i = 0
while ($i <= ${#options})
if ($options != "F" || $options != "D") then
goto USAGE
endif
@... (1 Reply)
Hi,
I need a help to search a pattern and print the multiple lines between them.
Input file:
Tue May 29 12:30:33 EDT 2012:threadWebContainer : 357:com.travimp.hotelierlinks.abba.service.RequestHandler.requestService(String, ITICSDataSet): hotelCancelReservation request: ... (4 Replies)
Hi Experts,
Need help with the following:
Desired output:
Only want to get the output marked in green.
The file:
--- Physical volumes ---
PV Name /dev/disk/disk4704
PV Status available
Total PE 6399
Free PE ... (3 Replies)
Hi all!
Thanks for taking the time to view this!
I want to grep out all lines of a file that starts with pattern 1 but also does not match with the second pattern.
Example:
Drink a soda
Eat a banana
Eat multiple bananas
Drink an apple juice
Eat an apple
Eat multiple apples
I... (8 Replies)
The intended result should be :
PDF converters
'empty line'
gpdftext and pdftotext?xml version="1.0"?>
xml:space="preserve"><note-content version="0.1" xmlns:/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size">PDF converters
gpdftext and pdftotext</note-content>... (9 Replies)
I have this fileA
TEST FILE ABC
this file contains ABC;
TEST FILE DGHT this file contains DGHT;
TEST FILE 123
this file contains ABC,
this file contains DEF,
this file contains XYZ,
this file contains KLM
;
I want to have a fileZ that has only (begin search pattern for will be... (2 Replies)
Discussion started by: vbabz
2 Replies
LEARN ABOUT BSD
unifdef
UNIFDEF(1) General Commands Manual UNIFDEF(1)NAME
unifdef - remove ifdef'ed lines
SYNOPSIS
unifdef [ -t -l -c -Dsym -Usym -idsym -iusym ] ... [ file ]
DESCRIPTION
Unifdef is useful for removing ifdef'ed lines from a file while otherwise leaving the file alone. Unifdef is like a stripped-down C pre-
processor: it is smart enough to deal with the nested ifdefs, comments, single and double quotes of C syntax so that it can do its job, but
it doesn't do any including or interpretation of macros. Neither does it strip out comments, though it recognizes and ignores them. You
specify which symbols you want defined -Dsym or undefined -Usym and the lines inside those ifdefs will be copied to the output or removed
as appropriate. The ifdef, ifndef, else, and endif lines associated with sym will also be removed. Ifdefs involving symbols you don't
specify are untouched and copied out along with their associated ifdef, else, and endif lines. If an ifdef X occurs nested inside another
ifdef X, then the inside ifdef is treated as if it were an unrecognized symbol. If the same symbol appears in more than one argument, only
the first occurrence is significant.
The -l option causes unifdef to replace removed lines with blank lines instead of deleting them.
If you use ifdefs to delimit non-C lines, such as comments or code which is under construction, then you must tell unifdef which symbols
are used for that purpose so that it won't try to parse for quotes and comments in those ifdef'ed lines. You specify that you want the
lines inside certain ifdefs to be ignored but copied out with -idsym and -iusym similar to -Dsym and -Usym above.
If you want to use unifdef for plain text (not C code), use the -t option. This makes unifdef refrain from attempting to recognize com-
ments and single and double quotes.
Unifdef copies its output to stdout and will take its input from stdin if no file argument is given. If the -c argument is specified, then
the operation of unifdef is complemented, i.e. the lines that would have been removed or blanked are retained and vice versa.
SEE ALSO diff(1)DIAGNOSTICS
Premature EOF, inappropriate else or endif.
Exit status is 0 if output is exact copy of input, 1 if not, 2 if trouble.
BUGS
Does not know how to deal with cpp consructs such as
#if defined(X) || defined(Y)
AUTHOR
Dave Yost
4.3 Berkeley Distribution April 29, 1985 UNIFDEF(1)