Obscure sed variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Obscure sed variable
# 1  
Old 04-22-2010
Obscure sed variable

Hello,
anyone could me explain what does this line script really do?[

Code:
( sed -e "/^#/d" -e "s/#.*$$//"  /var/tmp/map.cgd ) | ( awk '{for (i = 2; i <= NF; i++) print  $$i, $$0}' )

Moreover... why $$ on second sed instruction?!? What does it means?

Thanks
gb

---------- Post updated at 11:38 AM ---------- Previous update was at 11:09 AM ----------

FOUND : Well... it'is a Makefile, so $$ on sed means EOL and on awk $i and $0

sorry Smilie
# 2  
Old 04-22-2010
The "sed" is removing comment lines (lines starting with #) and the comment portion of lines containing comments (from # to the end of the line).
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Red Hat

How to pass value of pwd as variable in SED to replace variable in a script file

Hi all, Hereby wish to have your advise for below: Main concept is I intend to get current directory of my script file. This script file will be copied to /etc/init.d. A string in this copy will be replaced with current directory value. Below is original script file: ... (6 Replies)
Discussion started by: cielle
6 Replies

2. Red Hat

sed with variable

Hi Friends in sed whether we can use variable.like the following expression. sed -i 's/ABC/$var/g' filename I am using Kernel 2.6.18-194.11.1.el5 RedHat linux. I have tried sed -i 's/ABC/"$var"/g' filename, still not working.:( Please help. Thanks in advance Joy Double post,... (0 Replies)
Discussion started by: itsjoy2u
0 Replies

3. Shell Programming and Scripting

Expand an environment variable in sed, when the variable contains a slash

I'm trying to make a sed substitution where the substitution pattern is an environment variable to be expanded, but the variable contains a "slash". sed -e 's/<HOME_DIRECTORY>/'$HOME'/'This gives me the following error: sed: -e expression #1, char 21: unknown option to `s'Obviously this is... (2 Replies)
Discussion started by: Ilja
2 Replies

4. Shell Programming and Scripting

Obscure sed extraction syntax

Hi, Could anyone clearly explain me the below sed construct in detail to get to know what it actually does? sed 's/\(* *\)//4' echo 'test;10;20' | sed 's/*;\(*\)/\1/' (1 Reply)
Discussion started by: royalibrahim
1 Replies

5. Shell Programming and Scripting

Insert a line including Variable & Carriage Return / sed command as Variable

I want to instert Category:XXXXX into the 2. line something like this should work, but I have somewhere the wrong sytanx. something with the linebreak goes wrong: sed "2i\\${n}Category:$cat\n" Sample: Titel Blahh Blahh abllk sdhsd sjdhf Blahh Blah Blahh Blahh Should look like... (2 Replies)
Discussion started by: lowmaster
2 Replies

6. Shell Programming and Scripting

Sed variable substitution when variable constructed of a directory path

Hello, i have another sed question.. I'm trying to do variable substition with sed and i'm running into a problem. my var1 is a string constructed like this: filename1 filerev1 filepath1 my var2 is another string constructed like this: filename2 filerev2 filepath2 when i do... (2 Replies)
Discussion started by: alrinno
2 Replies

7. Shell Programming and Scripting

want to use variable in sed

hello i have following sed command works fine. sed -n 's/.*-L\(*\)myproject.*/\1/p' makefile > m here search words are -L and myproject now i want to replace these words by variables like var1="-L" var2="myproject" so the command would be like this sed -n... (3 Replies)
Discussion started by: shailesh_arya
3 Replies

8. Shell Programming and Scripting

sed (variable)

HOw can I use any variable in sed command. For example I am using 'sed -e 's/?/$ORACLE_HOME/g' $file_name Here it replaces ? with $ORACLE_HOME. Instead of it I need actual value of $ORACLE_HOME. How can I do that? Please advice. Thanks in advance. Malay (13 Replies)
Discussion started by: malaymaru
13 Replies

9. Shell Programming and Scripting

How can I use a variable in sed?

Hi I'm trying to change a part of a line with sed. Usually I will run sed 's/mytext/mynewtext/' Now I have a variable: var=mynewtext sed 's/mytext/$var/' does not work. I have also tried to protect the $ with different characters but it still does'nt work. I will be very happy if... (2 Replies)
Discussion started by: tromag
2 Replies
Login or Register to Ask a Question