Sponsored Content
Top Forums Shell Programming and Scripting Edit first line of a text file Post 302693645 by Corona688 on Wednesday 29th of August 2012 11:58:29 AM
Old 08-29-2012
Quote:
Originally Posted by gagandeep
Code:
 
sed 's/A/KO/g' > corona688.txt

it will change the text without opening the file.
I see. Something else had to open it in the first place, however, if not reading from stdin.
Quote:
or you can use
Code:
 
sed -i 's/A/KO/g'

this will save in the current file.
It does NOT save it in the current file. It deletes the file and creates a new one. This can have bad effects on file ownership and permissions.
This User Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Edit and insert character in a text file

Hello All, Can somebody please help me how to accomplish the following : I have a text file called data.txt that has the following information : M|88494-998494 M|98jd#0094 M|88394-994049 M|GFG9980#009944 and so on... I need to replace the value of M to either "S" or "X"... (3 Replies)
Discussion started by: negixx
3 Replies

2. UNIX for Dummies Questions & Answers

edit each line in the file

I am trying to edit each line in a file. The file has several columns delimitted by '|'. I need to take out the last two columns. Each line starts with a unique word through which I am storing the lines in a variable and cutting the last two colums. But, when I am echoing the line, it is... (2 Replies)
Discussion started by: chiru_h
2 Replies

3. Shell Programming and Scripting

Edit a line in a file with perl

Hi, How can I edit a line in a file? For example, a.txt contains: start: 1 2 3 4 stop: a b c d and I want to change "3" to "9" and to add "5" after "4" the result should be (a.txt): start: 1 9 3 4 5 stop: a b c d Thanks, zed (5 Replies)
Discussion started by: zed
5 Replies

4. Shell Programming and Scripting

Edit other than the first and last record of a text file

Hello, I have to add the string "YES" to the end of all records of files in a dir other than the first(header) and the last(trailer) record. viz, the first and the last record in a file has to be identified and exempted from the edit. I tried an awk script. But there seems to be no direct... (8 Replies)
Discussion started by: rogersed
8 Replies

5. UNIX for Dummies Questions & Answers

edit this text file

hi, i need to remove the first column (and dash) from this text file. Is there any unix command allowing me to do it ? 1-16 2-28 3-16 4-20 5- 8 6-32 7-19 8-16 9-27 10- 7 11-14 12-18 thanks (2 Replies)
Discussion started by: aneuryzma
2 Replies

6. Shell Programming and Scripting

How to get awk to edit in place and join all lines in text file

Hi, I lack the utter fundamentals on how to craft an awk script. I have hundreds of text files that were mangled by .doc format so all the lines are broken up so I need to join all of the lines of text into a single line. Normally I use vim command "ggVGJ" to join all lines but with so many... (3 Replies)
Discussion started by: n00ti
3 Replies

7. Shell Programming and Scripting

How to edit file to have one line entry?

Hello All, My file content is: DROP TABLE "FACT_WORLD"; CREATE TABLE "FACT_WORLD" ( "AR_ID" INTEGER NOT NULL, "ORG_ID" INTEGER NOT NULL ) DATA CAPTURE NONE COMPRESS YES; I want to change this file to have entries in one... (6 Replies)
Discussion started by: akash2508
6 Replies

8. Shell Programming and Scripting

Open the file and edit/append the text

Hi i have a file like this mailboxnum 20 filename <to subsitute> fileloaction /home/dd234/ filetype txt in a directory i have set of files for ex: TT45.1.2 TT45.1.3 TT45.1.4 . . in for loop i have to take this files and subsitute one by one ex: (1 Reply)
Discussion started by: greenworld123
1 Replies

9. Shell Programming and Scripting

Edit a Huge one line file

We have a huge file which has just one really large line; about 500 MB. I want to 1. Count all the occurrences of a phrase 2. Replace the phrase with another. Trying to open it using vi has not helped as it complains that it is too large. Can any script help? Please advise. Thank you, (12 Replies)
Discussion started by: kaushikadya
12 Replies

10. Shell Programming and Scripting

Script to edit a text file

hi, could someone share a short script that would process a .txt file and do the following, for example the text file has this form 0:1.0 1:1.0 2:2.0 3:3.0 4:4.0 5:5.0 6:6.0 7:7.0 8:8.0 ... {newline} 9:9.0 10:10.0 11:11.0 12:12.0 13:13.0 14:14.0 15:15.0 16:16.0 17:17.0 ... {newline} and I... (3 Replies)
Discussion started by: c_lady
3 Replies
TEXT2PS(L)																TEXT2PS(L)

NAME
text2ps - convert text files to PostScript SYNOPSIS
text2ps [ options ] [ files ] DESCRIPTION
Text2ps reads the input files (standard input if none are specified) and produces PostScript code which, when fed to a PostScript printer, will print the files. With text2ps it is possible to select any font, point size and number of columns. Options and files can be inter- mixed on the command line. Options are effective for all following files until they are overridden. Options Here follows a list of options that text2ps recognizes. Most numeric arguments are significant to one decimal place. Options are evalu- ated from left to right. Later options override earlier ones. -# n Print n copies of each page. (Default 1.) -c n Print in n columns. (Default 1.) -f font Print using font font. (Default Courier.) -p n Print with point size n. (Default 9.) -v n Use a vertical spacing of n points. If the vertical spacing is set to 0, the spacing will be 1.2 times the point size. (Default 0.) -l n Print n lines per column. When the line count is 0, print as many lines as will fit. (Default 0.) -r [p|l] Set the orientation to either portrait mode (p) or landscape mode (l). (Default p.) -b [+|-] Set page break mode. An argument + will force new files to be always printed on a new page (this is the default). After - new files will be put on the same page if there are still empty columns and the number of columns, the orientation or the number of copies didn't change. New files always start new columns. (Default -.) -mt n The top margin is n points. (Default 63.) -mb n The bottom margin is n points. (Default 63.) -ml n The left margin is n points. (Default 59.) -mr n The right margin is n points. (Default 59.) -mg n The inter-column gap is n points. (Default 25.) -t [+|-] If the argument is + the name of the file being printed will be printed on each page. If the argument is - the file name will not be printed. -t + implies -b +. -T text Print text as title on each page. This implies -t - and -b +. This option can be switched off by specifying -t - or -t +. (Default no title.) -F font Set the title font to font. (Default Helvetica.) -P n Set the title point size to n. (Default 12.) -B n Draw borders around each page. The number n specifies how to draw borders. N can have any of the following values or-ed in: 1 Draw a line along the left of the page. 2 Draw a line along the bottom of the page. 4 Draw a line along the right of the page. 8 Draw a line along the top of the page. 16 Draw a line between columns. This line does not connect to the lines along the top or bottom. 32 Draw a connecting line between the line between columns and the line along the top. 64 Draw a connecting line between the line between columns and the line along the bottom. When n is 0, no border lines are drawn. (Default no bordering lines.) -w n Tab stops are set every n spaces. Set the width of the TAB character. (Default 8.) -1 Sets up options to print in one column in portrait mode with the Courier font, so that you get 66 lines on a page. Equivalent to specifying the options -c 1 -f Courier -p 9 -v 0 -r p -l 0 -mt 63 -mb 63 -ml 59 -mr 59. This is the default. -2 Sets up options to print in two columns in landscape mode with the Courier font, so that you get two 66-line columns on a page. Equivalent to specifying the options -c 2 -f Courier -p 6 -v 0 -r l -l 0 -mt 63 -mb 63 -ml 59 -mr 59 -mg 25. Together with the -1 option, this is probably the most useful option. The name - means standard input. BUGS
Too many options. There is no way to specify where the title will be placed. If the font being used is not a constant width font and there are other characters than just tabs and spaces in front of a tab, the next character may not align properly. TEXT2PS(L)
All times are GMT -4. The time now is 02:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy