number sign(#) in sed scripts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting number sign(#) in sed scripts
# 1  
Old 02-01-2009
number sign(#) in sed scripts

Hi.

In a simple sed script i have number signs - #. But i can't find any description on their functionality. One thing that i find is that # in sed scripts can mean comment if it is placed in the beginning of the line.
I thought may be this undocumented(for me) behavior refers to regular expressions - but in regexp # doesn't mean anything special.

Script like that

VAR="1 2"
echo $VAR|sed 's# # & #'

and we get output

1 & 2

In this simple example i understand how it works. But i want full description to be confident when i change scripts. Any links?

thanks
# 2  
Old 02-01-2009
Wow.
I found. It is just a delimiter insteed of usual backslash. You can use any delimiter of regexp's in substitute command.
So the command

sed 's# # & #'

is the same as

sed 's/ / & /'

I should read sed & awk book for some chapters more.
Topic closed.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed - How to replace right part of equal sign (=) on a line

Hello. Using a bash script , I have a variable name for the file I want to modify FILE_TO_EDIT="/etc/my_config_file"And I have a variable name for the parameter to change PARAMETER="fallback_node" PARAMETER_NEW_VALUE="http://my_server_name.com/new_path" A config file may contain : 1°)... (2 Replies)
Discussion started by: jcdole
2 Replies

2. Homework & Coursework Questions

Asst: Using Shell Scripts with sed

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: One problem with the use of sed in simple text substitutions is that sed will intepret some characters as... (1 Reply)
Discussion started by: raymondbn
1 Replies

3. UNIX for Dummies Questions & Answers

Rename scripts using xargs/sed

Morning all I've got loads of scripts but the names are too long! I've stuck the list in a flat file (names) and I'm trying to read that in line by line and create the new names (in to directory new) from the list. It looks like this: xargs -n1 -I{} <names cat {} | sed... (1 Reply)
Discussion started by: Grueben
1 Replies

4. Homework & Coursework Questions

Help with Shell Scripts Using sed in multiple files.

Hi, I was hoping that someone could help me. I have a problem that i am trying to work on and it requires me to change text within multiple files using sed. What i have so far is !/bin/sh File1="$3" File2="$4" File3="$5" testNum="$File1" while test "$testNum" <= "$File3"; do echo... (12 Replies)
Discussion started by: Johnny2518
12 Replies

5. Shell Programming and Scripting

how to get data from hex file using SED or AWK based on pattern sign

I have a binary (hex) file I need to parse to get some data which are encoded this way: .* b4 . . . 01 12 .* af .* 83 L1 x1 x2 xL 84 L2 y1 y2 yL By another words there is a stream of hexadecimal bytes (in my example separated by space for better readability). I need to get value stored in... (3 Replies)
Discussion started by: sameucho
3 Replies

6. Shell Programming and Scripting

How to match floating number range in shell scripts?

for example: # I want to judge the value of $1 which should be $2<$1<$3. temp0=`echo "$1 - $2" | bc` temp1=`echo "$1 - $3" | bc` if ] ; then echo OK else echo False fi Please use code tags, thanks. (6 Replies)
Discussion started by: 915086731
6 Replies

7. Shell Programming and Scripting

Check existence of a number of files and call other scripts

Hi, I am new to unix scripting and am jus getting to learn about it.. I need to know on how to check for the existence of a number of files in a path..i.e the files are ftp'ed from several other servers, should check if all the files have arrived, if not wait till they arrive..can i use a flag... (5 Replies)
Discussion started by: yohasini
5 Replies

8. Shell Programming and Scripting

How to store a number along with the sign

If I use the below cut -c37-48, the minus sign does not get appended to the number, as the sign is in the 36th Position. But, If I use cut -c36-48, the minus sign appears infront of the number, but for positive numbers, it throws an error. How can this be resolved.. (7 Replies)
Discussion started by: Haimanti
7 Replies

9. Shell Programming and Scripting

sed scripts are not playing nicely!

I am having a lot of trouble, wasting a lot of time trying to get sed script files to run without problem. I have a list of scripts I want to run on a text file to turn it into a viewable html file for my mobile phone. Each of the single scripts when run in order/sequence one after another on the... (4 Replies)
Discussion started by: naphelge
4 Replies

10. Shell Programming and Scripting

Sign on/Sign off logging script

I'd like to make a script that I can execute every time I sign on to my linux box that keeps track of the time and allows to me to add a remark to a file. So basically once I log in, I run the script, and it outputs the date and time to a text file (log.txt). But that isn't my problem. I need... (1 Reply)
Discussion started by: Glider
1 Replies
Login or Register to Ask a Question