Removing SAS multi line comments in UNIX


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Removing SAS multi line comments in UNIX
# 1  
Old 07-25-2013
Removing SAS multi line comments in UNIX

i have to remove the commented (/* . . . .*/) part which starts in one line and ends in other.help me with generic code because i have 1000 to 10k lines code which i have to remove.

Code:
data one;
set work.temp;
input name age;
infile filename;
/* dfsdf
dsfs
sdfdf
dsdd
sdfsf
sdfsf
sfs
fsfs
dffsf */
if age > 10 the do;
/* people who have age 
 more than 10
*/ 
run;

I have tried below code:
Code:
sed 's#; */\*[^*]*\*/ *$#;#' filename.txt
egrep -v '/|/d' filename.txt
 sed -v '/\/\*/,/\*\//p' filename.txt


Last edited by saaisiva; 07-25-2013 at 11:58 AM..
# 2  
Old 07-25-2013
using awk:

Code:
nawk '/\/\*/{f=1;next}/\*\//{f=0;next}!f{print}' file


Last edited by Subbeh; 07-25-2013 at 09:21 AM..
# 3  
Old 07-25-2013
Hi Subbeh,

I am Getting error command not found when i run the above command.
# 4  
Old 07-25-2013
my bad, use awkinstead of nawk
# 5  
Old 07-25-2013
Hi Subbeh,

I am not getting the output when i run it in bash. it is blank
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Slack message multi line from UNIX script

Hi OS: Redhat Version 7.5 Enterprise Trying to post message from shell script to Slack channel and trying below code: text="$msg" text1="$lmsg" if ] then echo "No text specified" exit 1 fi escapedText=$(echo $text | $text1 | sed 's/"/\"/g' | sed "s/'/\'/g" )... (13 Replies)
Discussion started by: onenessboy
13 Replies

2. Shell Programming and Scripting

Help with reformat single-line multi-fasta into multi-line multi-fasta

Input File: >Seq1 ASDADAFASFASFADGSDGFSDFSDFSDFSDFSDFSDFSDFSDFSDFSDFSD >Seq2 SDASDAQEQWEQeqAdfaasd >Seq3 ASDSALGHIUDFJANCAGPATHLACJHPAUTYNJKG ...... Desired Output File >Seq1 ASDADAFASF ASFADGSDGF SDFSDFSDFS DFSDFSDFSD FSDFSDFSDF SD >Seq2 (4 Replies)
Discussion started by: patrick87
4 Replies

3. Shell Programming and Scripting

Reading Multi Line SQL in UNIX

Hello, Currently, I am reading few queries from the below .sql file --SOURCE TABLE NAME --SOURCE QUERY SEL COL1, COL2, COL3, COL4, COL5, COL6, COL7 WHERE COL5 = '2015-11-04 16:24:00.000000' FROM SOURCE TABLE; --TARGET TABLE NAME --TARGET QUERY SEL COLUMN1, COLUMN2, COLUMN3, COLUMN4,... (4 Replies)
Discussion started by: ronitreddy
4 Replies

4. Shell Programming and Scripting

Removing ^M from last line alone of a UNIX File

Hi All, I am copying a file from windows to UNIX. After that copying it have the ctrl+M character in the file at the line break. But the file contains the data that also have ctrl+M. I want to re move the ctrl+M at the end of the line alone. My file structure is XML and last line doesnt... (3 Replies)
Discussion started by: Agantrope
3 Replies

5. UNIX for Dummies Questions & Answers

Remove multi line and single line comments

Hi, I am trying to remove multi line and single line comments like examples below I have tried this pattern. it works fine for single line comments and multi line comments in a single line only. but this fails when the comments are extended in multiple lines as shown in the comment 2 of... (3 Replies)
Discussion started by: ahmedwaseem2000
3 Replies

6. Shell Programming and Scripting

Removing the sas comment line using UNIX

I have tried a lot, Need your help guys. SAS Program: data one ; /* Data step */ Input name $; /*Dec variables*/ I want to remove the commented part(/* Data step */) alone. I have tried using sed command but it is deleting the entire line itself. i need unix command to separate this and... (6 Replies)
Discussion started by: saaisiva
6 Replies

7. UNIX for Dummies Questions & Answers

Remove SAS comments using UNIX

I have tried a lot, Need your help guys. SAS Program: data one ; /* Data step */ Input name $; /*Dec variables*/ I want to remove the commented part(/* Data step */) alone. I have tried using sed command but it is deleting the entire line itself. i need unix command to separate this and... (1 Reply)
Discussion started by: saaisiva
1 Replies

8. Shell Programming and Scripting

Multi-line filtering based on multi-line pattern in a file

I have a file with data records separated by multiple equals signs, as below. ========== RECORD 1 ========== RECORD 2 DATA LINE ========== RECORD 3 ========== RECORD 4 DATA LINE ========== RECORD 5 DATA LINE ========== I need to filter out all data from this file where the... (2 Replies)
Discussion started by: Finja
2 Replies

9. Shell Programming and Scripting

Removing Multiple Line comments

:) Hi all, I would like to remove all multiple line comments, in between the pattern /*.....*/ from my file. The comments can be expected to be at any place in my file, like this: /*.... This multi line comment might stretch even the entire file..! ......*/ Some text Text1 /* Comment... (25 Replies)
Discussion started by: Jackuar
25 Replies

10. Shell Programming and Scripting

removing comments from file

I'm doing manual way to add and remove "#" on etc/services. Is there anyway I can modify the file using awk or sed or any other program. I use vi to modify /etc/services for enabling telnet , the problem is I don't know how to do it automatically in script. production state: #telnet ... (9 Replies)
Discussion started by: skully
9 Replies
Login or Register to Ask a Question