Manipulating a variable using sed (solved)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Manipulating a variable using sed (solved)
# 1  
Old 06-13-2011
Manipulating a variable using sed (solved)

Hi,

My variable has value as this:
tvar1="bool_risk_enabled" Boolean "true"

Now I need to replace this true with false. Which is the best way to do this? Can we do this with sed command?

Please help me.

---------- Post updated at 05:23 PM ---------- Previous update was at 05:00 PM ----------

Code:
tvar3=$(echo ${tvar2} | sed -e's/true/false/')
echo ${tvar3}

This worked. Thanks to myself
# 2  
Old 06-13-2011
Code:
${tvar1/true/false}

This User Gave Thanks to yinyuemi For This Post:
# 3  
Old 06-14-2011
I'm getting below error, when I tried
Code:
${tvar1/true/false}

test5.sh: line 8: false: command not found
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] How to increment and add variable length numbers to a variable in a loop?

Hi All, I have a file which has hundred of records with fixed number of fields. In each record there is set of 8 characters which represent the duration of that activity. I want to sum up the duration present in all the records for a report. The problem is the duration changes per record so I... (5 Replies)
Discussion started by: danish0909
5 Replies

2. Shell Programming and Scripting

Manipulating sed Direct Input to Direct Output

Hi guys, been scratching round the forums and my mountain of resources. Maybe I havn't read deep enough My question is not how sed edits a stream and outputs it to a file, rather something like this below: I have a .txt with some text in it :rolleyes: abc:123:xyz 123:abc:987... (7 Replies)
Discussion started by: the0nion
7 Replies

3. Shell Programming and Scripting

Manipulating xyz file with awk-if-else or sed

Hi forum, I am really hoping somebody can please help me here. I have a dataset in xyz format, with longitude as x, latitude as y and data readings as z. eg. 0 90 -8 1 90 23 2 90 -4 etc etc etc What i am looking to do is format the data so that x and y are untouched, however in... (2 Replies)
Discussion started by: shlam16
2 Replies

4. Shell Programming and Scripting

Need help in manipulating string variable

I have written a shell script to do some processing and have to manipulate a variable. Basically, the variable is like this -- var=set policy:set cli My purpose is to split it into two variables based on the position of ":". To get the right end, I am doing this -- vaa1=${vaa#*:} ... (1 Reply)
Discussion started by: Dev_Sharma987
1 Replies

5. Shell Programming and Scripting

Manipulating a header file using awk or sed

Hi Guys, Is there a simple way of doing the below. Available<spaces>Assigned<spaces>Maximum<spaces>Maximum<spaces>Page<spaces>Total <spaces>Used<spaces>Pct<spaces>Max. Pct<CR> Space<spaces>Capacity<spaces>Extension<spaces>Reduction<spaces>Size<spaces>... (8 Replies)
Discussion started by: eo29
8 Replies

6. Shell Programming and Scripting

Manipulating the etc/passwd file with sed

How can i use sed to extract the user name and home directory from the /etc/passwd/ file on my server. (11 Replies)
Discussion started by: Pauline mugisha
11 Replies

7. Shell Programming and Scripting

manipulating Fields in file using SED

Hi, I have two issues: I have one file say file1.dat and its over 3GB. It contains pipe delimited fields. The first line in the file is the header field which tells the column names etc. and from second line it's the data fileds with pipe delimited. Something like below: ... (5 Replies)
Discussion started by: rkumar28
5 Replies

8. Shell Programming and Scripting

Manipulating a variable across multiple shell scripts

I have a shell script similar to: #!/bin/sh a=1 source a1.sh -- Modifies a source a2.sh -- Modifies a echo "After execution, value of a is $a" What i need is a1.sh script modify the same variable a and same with a2.sh. Now the echo "After execution, value of a is $a" should print the... (1 Reply)
Discussion started by: indianjassi
1 Replies

9. Shell Programming and Scripting

Manipulating data in variable

Hi, I have two variables - A and B - containing a bunch of file paths. I am comparing them and when I find a match I want to remove that entry from A so that as the compare proceeds A shrinks entry by entry. How can I remove a matched entry from A whilst leaving the non matched entries... (6 Replies)
Discussion started by: ajcannon
6 Replies

10. Shell Programming and Scripting

Manipulating awk $variables using sed?

I have been searching around the forums here trying to find a solution to my problem but not getting anywhere but closer to baldness. I have a 20 column pipe "|" seperated text file. The 14th variable doesnt always exist, but will have the format of YYYYMM or YYYY if it does. I need to take... (2 Replies)
Discussion started by: r0sc0
2 Replies
Login or Register to Ask a Question