Sponsored Content
Full Discussion: grep matter between braces
Top Forums Shell Programming and Scripting grep matter between braces Post 302297696 by Corona688 on Saturday 14th of March 2009 02:25:07 PM
Old 03-14-2009
Code tags for code, please, otherwise the forum will strip all the spacing from it and make it unreadable. [ code ] stuff [ /code ] without the extra spaces in the tags.

Since nearly all whitespace in C is interchangable, I might try rearranging it to remake the lines more to my pleasing:
  • Rip out all preprocessor lines: egrep -v '^#|\\$' This does not do a perfect job, involving the C++ preprocessor would do better but would be more complex.
  • Replace all linefeeds with spaces: tr '\n' ' '
  • Replace "}" with "}\n" and "{" with "\n{": sed 's/}/}\n/g;s/{/\n{/g'

So:
Code:
$ echo "#include <stdio.h>

int main(void)
{
        int i=3;
        if(i==2)
        {
                something();
        }
        else
        {
                something_else();
        }

        return(0);
}" > omg.c

$ grep -v '^#' < omg.c | tr '\n' ' ' | sed 's/{/\n{/g;s/}/}\n/g'
 int main(void) 
{         int i=3;         if(i==2)         
{                 something();         }
         else         
{                 something_else();         }
          return(0); }
$

Perhaps you'd find that output easier to find what you wanted in.
 

7 More Discussions You Might Find Interesting

1. Linux

Need help with this matter

I have a PC that was built in Europe pre-installed with Windows 2000. The HDD is 40GB, but, its split up as two 20GB (Taken up by Windows). I want to take over my Mandrake 9.1 CDs and install Linux on that machine. My question is, how would I proceed to install Linux this way??? Now, If... (1 Reply)
Discussion started by: wardialer
1 Replies

2. Shell Programming and Scripting

grep to find content in between curly braces, "{" and "},"

problem String ~~~~~~~~~~~~~~~~~~ icecream= { smart peopleLink "good" LC "happy" , smartpeopleLink "dull" LC "sad" } aend = {smart vc4 eatr kalu} output needed ~~~~~~~~~~~~~~~~~~ smart peopleLink "good" LC "happy" , smartpeopleLink "dull" LC "sad" smart vc4... (4 Replies)
Discussion started by: keshav_rk
4 Replies

3. Shell Programming and Scripting

How to delete matter in between two lines

help I am having text file like this... ------------------------END OF UPDATION ------------------ xxxxxxxxxxxxxxxxxxxxxxxxx yyyyyyyyyyyyyyyyyyyyy yyyyyyyyyyyyyyyyyyyyy 1 row updated ------------------------END OF UPDATION ------------------ TTTTTTTTTTTTTTTT FFFFFFFFFFFFFFFFF ... (3 Replies)
Discussion started by: suryanarayana
3 Replies

4. Shell Programming and Scripting

Terminal to the front no matter what

Is there a way to bring the terminal script to the front? I am running this script through OMCEdit which is then running it through Terminal. I have some dialog boxes (using osascript) and the dialog boxes are not coming to the front...Terminal bounces and I have to click on Terminal to see the... (1 Reply)
Discussion started by: mainegate
1 Replies

5. Solaris

Does file extension matter in UNIX?

Hi friends, I was wondering if UNIX programs really care about file extensions like Microsoft Windows applications do. Because I think an extension doesn't really change the nature of a file, or does it? But when I try to compile the c source code file named "hello", gcc gives me error, saying... (1 Reply)
Discussion started by: gabam
1 Replies

6. Shell Programming and Scripting

For getting value between the braces

Hi I have a file called tmp with the content as belowmore tmp NAMELIST(Hari) NAMELIST(Raju) I want to get the values between the brackets. When I executed the below command on zlinux I get the output which I wantedmore tmp |awk -F'' '{print $2}' But when I execute the same in... (3 Replies)
Discussion started by: harimhkr
3 Replies

7. Shell Programming and Scripting

Code that has to end no matter what

Since this is maxxing out my CPU, is there anything I can add that will make sure stress always ends? echo "CPU Stress Test" >> CPU_Stress_Test.txt echo "stress --cpu 8 --io 4 --vm 2 --vm-bytes 128M --timeout 1m" >> CPU_Stress_Test.txt echo >> CPU_Stress_Test.txt date +"%Y-%m-%d-%H-%M" >>... (9 Replies)
Discussion started by: drew77
9 Replies
ppmtosixel(1)                                                 General Commands Manual                                                ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 01:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy