04-20-2008
Replacing line with a new file in a file
Hi,
I have a txt file which contains:
Apple is red.
Orange is orange.
Banana is yellow.
Strawberry is red.
-eof-
How do I go about replacing "Banana is yellow" with "Cherry is red"? I tried to use seekp to get the position of Banana and replace that line but unable to.
Please advise. Thanks.
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
hey guys, how do i replace only a line within a file without messing up the rest of the contents of the file?
see, if possible can you guys give me a straight forward way to do this. i dont want a complex command. what i mean is i know i can accomplish this by using sed, well, i think i can,... (3 Replies)
Discussion started by: Terrible
3 Replies
2. Shell Programming and Scripting
Hi,
Apologies if this has been asked before, but I searched and was not able to find an answer. It's probably a simple question to answer for those of you with some experience, though...
I have a relatively long string where tokens are separated by the colon (':') character. Let's say the... (10 Replies)
Discussion started by: johnemb
10 Replies
3. Shell Programming and Scripting
Hi All
I have a requirement where using a script I grep a file for string (KSG/Password in below ) , get the next line which is the password and I need replace the whole line of unknown special charecters (encrypted password) with another line as given below .
As in below i need to get... (12 Replies)
Discussion started by: malavm
12 Replies
4. Shell Programming and Scripting
I have a problem in the following code ...
while read line
do
#Get Line Number
OLDLINE=`sed -n $Lineno $filename`
echo "Un Changed Line : "$OLDLINE
echo "Enter a New Pattern : "
read NewPattern <&1
echo "NewPattern :"$NewPattern
NEWLINE=`cat $filename | sed -n... (1 Reply)
Discussion started by: maxmave
1 Replies
5. Shell Programming and Scripting
Hello,
I have a csv file and will like to replace the last character of each line in the file with Z (20 Replies)
Discussion started by: 123script
20 Replies
6. UNIX for Dummies Questions & Answers
Hi All,
I have a set of files named S5_SK1.chr01 S5_SK1.chr02 S5_SK1.chr03 ..... and the first line of these files is >SK1.chr01 >SK1.chr02 >SK1.chr03 ..... Can anyone suggest how I can change the first line of all these files with the filename itself? So my expected output for the first lines of... (14 Replies)
Discussion started by: pawannoel
14 Replies
7. Shell Programming and Scripting
Hi All,
As mentioned in the title I have two text files and I would like to replace line number 5 of file #1 with line number 4 of file #2
e.g.
file 1
wqwert
4.4464002
3
319
286
369
46.320002
56.150002
45.100002
1
1
1
0.723 (12 Replies)
Discussion started by: f_o_555
12 Replies
8. Shell Programming and Scripting
I have a file which has a list in it
pop
triangle
people
slow
fast
What I want to do is search this list and replace people with humans do the list looks like this:
pop
triangle
human
slow
fast
I think i use something like this....
if cat /list.txt | grep -q 'people' ; then (9 Replies)
Discussion started by: digitalviking
9 Replies
9. Shell Programming and Scripting
Hi all,
I need to replace a line
export TZ=xxxxxxxx
with the line
export TZ=$1
Now, "xxxxxxxx" in the above line is some unknown string and $1 is a parameter. I want the content of $1 to be replaced with "xxxxxxxx".
Kindly help me how to do this in the shell scripting. (5 Replies)
Discussion started by: ddeeps2610
5 Replies
10. Shell Programming and Scripting
Hi Guys,
I am having a set of date format files files where I am performing the below set of operations in the files . I Need to replace the last line value with specific date which is a pipe delimited file.
for egf1_20140101.txt
aa|aus|20140101|yy
bb|nz|20140101|yy
.
.... (19 Replies)
Discussion started by: rohit_shinez
19 Replies
LEARN ABOUT CENTOS
secolor.conf
secolor.conf(5) File Formats Manual secolor.conf(5)
NAME
secolor.conf - The SELinux color configuration file
DESCRIPTION
This optional file controls the color to be associated to the context components associated to the raw context passed by selinux_raw_con-
text_to_color(3), when context related information is to be displayed in color by an SELinux-aware application.
selinux_raw_context_to_color(3) obtains this color information from the active policy secolor.conf file as returned by selinux_col-
ors_path(3).
FILE FORMAT
The file format is as follows:
color color_name = #color_mask
[...]
context_component string = fg_color_name bg_color_name
[...]
Where:
color
The color keyword. Each color entry is on a new line.
color_name
A single word name for the color (e.g. red).
color_mask
A color mask starting with a hash (#) that describes the hexadecimal RGB colors with black being #000000 and white being #ffffff.
context_component
The context component name that must be one of the following:
user, role, type or range
Each context_component string ... entry is on a new line.
string
This is the context_component string that will be matched with the raw context component passed by selinux_raw_context_to_color(3).
A wildcard '*' may be used to match any undefined string for the user, role and type context_component entries only.
fg_color_name
The color_name string that will be used as the foreground color. A color_mask may also be used.
bg_color_name
The color_name string that will be used as the background color. A color_mask may also be used.
EXAMPLES
Example 1 entries are:
color black = #000000
color green = #008000
color yellow = #ffff00
color blue = #0000ff
color white = #ffffff
color red = #ff0000
color orange = #ffa500
color tan = #D2B48C
user * = black white
role * = white black
type * = tan orange
range s0-s0:c0.c1023 = black green
range s1-s1:c0.c1023 = white green
range s3-s3:c0.c1023 = black tan
range s5-s5:c0.c1023 = white blue
range s7-s7:c0.c1023 = black red
range s9-s9:c0.c1023 = black orange
range s15:c0.c1023 = black yellow
Example 2 entries are:
color black = #000000
color green = #008000
color yellow = #ffff00
color blue = #0000ff
color white = #ffffff
color red = #ff0000
color orange = #ffa500
color tan = #d2b48c
user unconfined_u = #ff0000 green
role unconfined_r = red #ffffff
type unconfined_t = red orange
user user_u = black green
role user_r = white black
type user_t = tan red
user xguest_u = black yellow
role xguest_r = black red
type xguest_t = black green
user sysadm_u = white black
range s0:c0.c1023 = black white
user * = black white
role * = black white
type * = black white
SEE ALSO
selinux(8), selinux_raw_context_to_color(3), selinux_colors_path(3)
SELinux API documentation 08 April 2011 secolor.conf(5)