Sponsored Content
Top Forums Shell Programming and Scripting Inserting a new line into an already existing file Post 302667505 by zedex on Friday 6th of July 2012 11:03:16 AM
Old 07-06-2012
Quote:
Originally Posted by hemalathak10
when i call this command using from a perl script

i am getting the following errors

Code:
system("perl -pe '$_="11111\n$_" if $.==1;$_.="2222\n3333\n" if $.==6'sample.txt");

still i am getting the same errors
1. If you are running a command from perl why don`t you open file directly and do it with perl OPEN function?
2. while you are running the command you need to escape $ & " in command line, those are intended to be used on command line. When you use the command this way your running program is replacing those values! also ' " ' is completing the statement in mid way.

Try :

Code:
system("perl -pe '\$_=\"11111\\n\$_\" if \$.==1;\$_.=\"2222\\n3333\\n\" if \$.==6' sample.txt");

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Print one line of Existing File

Hi all, I need to know what command/s I can use to print lines from a file. I cannot do pattern matching, so grepping for a string is not possible. I'd like to say "print line 3" etc. Any ideas? Ta. (2 Replies)
Discussion started by: danhodges99
2 Replies

2. UNIX for Dummies Questions & Answers

Inserting Date&Time Stamp In Existing Log File

I am trying to insert a line with a date stamp in a file that is used to monitor activity in one of our directories. By doing this, I want to grep that file each day and go to the last entry for each time a error occurred and pull all errors generated if any exist. If error exists I want that error... (3 Replies)
Discussion started by: shephardfamily
3 Replies

3. Shell Programming and Scripting

Inserting New Line in File using Sed ??

Dear All, I have a file called football where i have a list of 11 players each on different lines. I wish to add a name of another player on the first line. I have created a file called footballscript in vi writing the following sed command to achieve this ... cat football | sed -e '1 i\... (4 Replies)
Discussion started by: Mary_xxx
4 Replies

4. Shell Programming and Scripting

comparing and inserting common line in other file

Hi, I have two files-- file1- file2:- i have to compare two files and where the uid is same i have to take the password and insert it above the telephone number. the output should be like this-- uid : 1418 common so insert the password thbs above the line telephonenumber. (2 Replies)
Discussion started by: namishtiwari
2 Replies

5. Shell Programming and Scripting

inserting a new line in a file

I'm sure you guys have answered this elsewhere but I can't seem to find where so here goes. #!/bin/bash n=120 a=$(sed '120q;d' energy.xvg) while ;do a=$(sed $n'q;d' energy.xvg) echo "$a \n" > newfile n=$(($n+100)) done exit 0 that script should read the file energy.xvg, start at... (1 Reply)
Discussion started by: gelitini
1 Replies

6. Shell Programming and Scripting

Need Help in Inserting a new line in a file using PERL

I need a perl script to find and replace a specific pattern in a file to a new line. BAsically I have a single line data in a file with 10 mb to 200 MB. I want to put a new line based on a specific pattern to open the file in Excel / Access. Following is the sample data in a file ... (1 Reply)
Discussion started by: portalfaq
1 Replies

7. Shell Programming and Scripting

inserting line to a file

I have posted it previously but somehow could not delete the previous post.I felt i could not explain the problem statement well. Here t goes.I have a file say File1. Now i need a specific pattern from the lines to be added to the other line. File: red blue green ABC.txt@ABC END black... (1 Reply)
Discussion started by: ngupta
1 Replies

8. Shell Programming and Scripting

Inserting IP in one line of a file

Hi, I have this line: ip=111.222.133.144,mac=00:16:3E:2A:08:3C,vifname=veth360','ip=10.2.3.4,vifname=veth360a' ^ | ------- I want to insert this IP 144.133.222.111 between "144"... (4 Replies)
Discussion started by: iga3725
4 Replies

9. Shell Programming and Scripting

Inserting a line in a file after every alternate line

Friends , I have a large file and i need to insert a line after every line.I am actually unaware how to do it.Any help appreciated. My File control station *ATM* , qread $OSS.Jul13A.FI01 interval 1 intcount 1 control station *ATM* , qread $OSS.Jul13A.FI02 interval 1 intcount... (4 Replies)
Discussion started by: appu2176
4 Replies

10. Shell Programming and Scripting

Inserting a line to a file

Hi, consider a file called mobile.txt as follows: For type lovers, add a new line at the end of it by copying its previous line and add a +1 to the field1, field2 Additionally, there are only 3 plans available to lovers type, so it should not work for lovers type already having 3 lines under... (11 Replies)
Discussion started by: Gautham
11 Replies
PYFORMEX(1)						      text and X11 processing						       PYFORMEX(1)

NAME
pyformex - generate and transform 3D geometry using Python scripts SYNOPSIS
pyformex [options] [ [ file [args] ] ...] DESCRIPTION
This manual page documents briefly the pyformex command. pyFormex is a program for generating, transforming and manipulating large geometrical models of 3D structures by sequences of mathematical operations. Thanks to a powerful (Python based) scripting language, pyFormex is very well suited for the automated design of spatial frame structures. It provides a wide range of operations on surface meshes, like STL type triangulated surfaces. There are provisions to import medical scan images. pyFormex can also be used as a pre- and post-processor for Finite Element analysis programs. Finally, it might be used just for creating some nice graphics. Using pyFormex, the topology of the elements and the final geometrical form can be decoupled. Often, topology is created first and then mapped onto the geometry. Through the scripting language, the user can define any sequence of transformations, built from provided or user defined functions. This way, building parametric models becomes a natural thing. While pyFormex is still under development, it already provides a fairly stable scripting language and an OpenGL GUI environment for dis- playing and manipulating the generated structures. OPTIONS
The pyformex command follows the usual GNU command line syntax, with long options starting with two dashes ('-'). The non-option arguments are filenames of existing pyFormex scripts, possibly followed by arguments, that will be executed by the pyFormex engine. If a script file uses arguments, it is responsible for removing the arguments from the list. A summary of the most important options is included below. A complete overview is can be found from the 'pyformex -h' command. For a com- plete description of the use and operation of pyFormex, see the online documentation at http://pyformex.org/doc or the documentation included with the distribution. --gui start the GUI (default if no file argument is given) --nogui do not load the GUI (default if a file argument is given) --interactive, -i Go into interactive mode after processing the command line parameters. This is implied by the --gui option. --config=<file> Read configuration settings from <file>, if it exists. --nodefaultconfig Skip the default site and user config files. This option can only be used in conjunction with the --config option. --redirect Redirect standard output to the message board (ignored with --nogui) --debug display debugging info to standard output --whereami Show where the pyformex package is installed and exit --detect Show detected helper software and exit --version Show the program's version number and exit. --help, -h Show the help message and exit. SEE ALSO
http://pyformex.org/doc/ AUTHORS
pyFormex is developed by Benedict Verhegghe with the help of the other pyFormex project members: Gianluca De Santis, Francesco Iannaccone, Peter Mortier, Tomas Praet, Sofie Van Cauter, Wenxuan Zhou. AUTHOR
Benedict Verhegghe <benedict.verhegghe@ugent.be>. This manual page was written for the Debian project (and may be used by others). COPYRIGHT
GPL v3 or higher 0.1 2011-12-29 PYFORMEX(1)
All times are GMT -4. The time now is 10:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy