Sponsored Content
Full Discussion: Redirect overwrites itself
Top Forums Shell Programming and Scripting Redirect overwrites itself Post 302423691 by alister on Friday 21st of May 2010 05:39:44 PM
Old 05-21-2010
Quote:
Originally Posted by rlopes
I bet many people faced this problem before:

The command below will result in a blank file:

Code:
$ cat myfile | grep pattern > myfile

Is there any easy way to do it?
Not sure if this qualifies as "easy", but if you're the adventurous type:
Code:
(rm myfile; grep -v pattern > myfile) < myfile

I elaborate on how this works and the risks involved at the end of the post at https://www.unix.com/302407978-post5.html

Regards,
Alister
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash overwrites data on screen!!

hi everybody, when i run and compile this: printf("test"); fflush(stdout); nothing appears on screen. if i try this: ___________________________________ printf("test"); fflush(stdout); sleep(10); ___________________________________ then i can see the output "test"... for 10... (4 Replies)
Discussion started by: brain_processin
4 Replies

2. IP Networking

Redirect

I'm sittig behind a firewall that doesn't allow ftp. I have a conection to a UNIX system, connecting throug SSH. Is it possible to redirect the ftp through the UNIX to my computer? (1 Reply)
Discussion started by: <Therapy>
1 Replies

3. Shell Programming and Scripting

Redirect question

Hi, I need some help to achive the follwoing task: I have a file named test that contain the following line: 'Hellow world','good morning' I want to attach the content of this file to a variable named var , and then rediarect it to a second file bamed test_new. The result should look like... (2 Replies)
Discussion started by: yoavbe
2 Replies

4. Programming

Redirect Browser

Hello guys, Is it possible to redirect browser to another socket address? Cheers, Elton (1 Reply)
Discussion started by: EltonSky
1 Replies

5. UNIX for Dummies Questions & Answers

ambiguous redirect

i have following statement in the script echo -e "$str_XML_col_name:$str_field_type;" >> $i_DC_Key_$i_Tgt_DC_key_Schema here $i_DC_Key is DC key and $i_Tgt_DC_key are the variables............... when i ran the script i am getting error rec_merge.sh: $i_DC_Key_$i_Tgt_DC_key_Schema:... (1 Reply)
Discussion started by: mahabunta
1 Replies

6. UNIX for Dummies Questions & Answers

Redirect to variable

how do you redirect stdout into a variable. whenever I try I get an ambiguous redirect error :( I am trying to validate some user input and failing miserably. cal $MONTH $YEAR | grep -c "$DAY" if the above is 1 then it is valid if 0 then not valid. I have been trying to redirect the output... (2 Replies)
Discussion started by: MrAd
2 Replies

7. Shell Programming and Scripting

Cannot redirect ouput?????

Hello experts, I'm testing a program that prints error message to the screen. I want to redirect the output to a file using >. but the message only prints on screen and not writing to the file, Any suggestion on what I might try? (3 Replies)
Discussion started by: minifish
3 Replies

8. Programming

pthread_mutex_trylock() overwrites global variable on CentOS5

Hi all, I am new to linux and got problem with pthread_mutex_trylock(). I have used mutex in my code. When I try to call pthread_mutex_trylock() on RECURSIVE type of mutex it overwrites adjacent memory location (that is global variable of type structure say x, memory allocated using malloc()). ... (5 Replies)
Discussion started by: liveshell
5 Replies

9. Windows & DOS: Issues & Discussions

gVim on windows 7 64 constantly overwrites symbolic and even hard links

I use sugarsync to sync my vimrc across computers. I keep the _vimrc file in a syncing folder and in my home folder, I have a symbolic link ~\_vimrc pointing to ~\Synced Docs\_vimrc. On my mac I have a .vimrc symbolic link pointing at the _vimrc file. On the pc side, every time I open the _vimrc... (3 Replies)
Discussion started by: dp88
3 Replies

10. UNIX for Dummies Questions & Answers

Sendmail MX redirect

Hi I have a working sendmail setup for my domain, but would like to run a subdomain on another machine. I could try below, but its a production server and worry about messing it up. Hence the question. So I have machine names: mydomain.com (mail server) dev.mydomain.com currently the... (1 Reply)
Discussion started by: gtrava01
1 Replies
rsvg(1) 							   User Commands							   rsvg(1)

NAME
rsvg - convert SVG files into raster images SYNOPSIS
rsvg [--dpi-x=number] [--dpi-y=number] [--format png|jpeg] [--height=integer] [--quality=integer] [--version] [--width integer] [--x-zoom number] [--y-zoom number] infile.svg outfile.png | outfile.jpeg DESCRIPTION
rsvg converts SVG images into PNG and JPEG raster images. OPTIONS
The following options are supported: -d --dpi-x=number Set the X resolution of the image in pixels per inch. The default value is 90dpi. -p --dpi-y=number Set the Y resolution of the image in pixels per inch. The default value is 90dpi. -f, --format png|jpeg Specify the output format for the converted image. The default value is png. -h, --height=integer Specify the height of the converted image. The default value is the height of the original image. -h, --quality=integer JPEG quality value -v --version Display rsvg version information. -w, --width integer Specify the width of the converted image. The default value is the width of the original image. -x, --x-zoom number X Zoom factor, as a percentage. The default value is 1.0. -y, --y-zoom number Y Zoom factor, as a percentage. The default value is 1.0. OPERANDS
The following operands are supported: infile.svg The name of the input SVG file. outfile.png The name of the converted PNG file. outfile.jpeg The name of the converted JPEG file. EXAMPLES
Example 1: Converting an SVG Image to PNG example% rsvg myfile.svg myfile.png Example 2: Converting an SVG Image to JPEG at 300dpi Resolution example% rsvg -f jpeg -d 300 myfile.svg myfile.jpg EXIT STATUS
The following exit values are returned: 0 Application exited successfully >0 Application exited with failure FILES
The following files are used by this application: /usr/bin/rsvg Executable to convert SVG files into raster images ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWlibrsvg | +-----------------------------+-----------------------------+ |Interface stability |Volatile | +-----------------------------+-----------------------------+ SEE ALSO
http://librsvg.sourceforge.net/ http://www.w3.org/TR/SVG11/ librsvg-2(3), attributes(5) NOTES
Original man page written by Dom Lachowicz (cinamod@hotmail.com), Alex Larsson (alex@redhat.com), and others. Updated by Laszlo Peter, Sun Microsystems Inc., 2004. SunOS 5.11 7 Sep 2004 rsvg(1)
All times are GMT -4. The time now is 04:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy