Remove comments from file with specific file name extensions


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remove comments from file with specific file name extensions
# 1  
Old 02-21-2013
Remove comments from file with specific file name extensions

Hello Unix board community,

I have to program a shell script, but I am a complete noob so I hope I get some help here. The assignment is as follows:

The program removes all comments regardless of formatting or language from files with specific file name extensions (php, css, js, ...).
Optional an own parameter file, which contains a list of file name extensions shall be provided. Optional the source and destination directory shall be provided.

How to start the script:
removecomment <file> [-L list] [-s sourcedir] [-d destinationdir]

The text without the comments is output to stdout

So, the list contains the comment syntax for each file name extension. What would be the best way to store the information into the list?
What do the -L -s -d mean and how do I use them in my script?

For the actual cutting I tried to do something like this
Code:
cut -d "#" -f1 withcomments.txt

But this is still hard coded and not distinct to the file name extension...

I don't really know where to start, I hope someone can help me.

With kind regards TheZeusMan
# 2  
Old 02-21-2013
Is this homework?
# 3  
Old 02-21-2013
Yeah, but I don't expect you to write the full program for me. I just need some infirmatn where to start.
# 4  
Old 02-21-2013
For class / homework you are to post here:
Homework & Coursework Questions - The UNIX and Linux Forums
There are special rules and we are strict on this for your own sake so start reading the README files there and repost correctly

Best regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove Specific Column in a File using awk

Hi, I would like to ask your expertise to remove specific column no. 8 in the below file using but I don't have an idea on how to simply do this using awk command. Appreciate your help in advance. Input f: ABC 1 1XC CDA 1 2YC CCC 1 3XC AVD 1 3XA Expected output file: ABC 1 1C CDA... (9 Replies)
Discussion started by: zzavilz
9 Replies

2. UNIX for Advanced & Expert Users

Watch directory and move specific file extensions

Hi all, This is actually more for my lazyness then anything else, but I think others might find it useful to use as well. Basically this is what I am trying to achieve... In my ubuntu home dir under Downloads is where firefox saves everything by default, now I know that you can manually... (3 Replies)
Discussion started by: STOIE
3 Replies

3. UNIX for Dummies Questions & Answers

Remove blank lines and comments from text file

Hi, I am using BASH. How can I remove any lines in a text file that are either blank or begin with a # (ie. comments)? Thanks in advance. Mike (3 Replies)
Discussion started by: msb65
3 Replies

4. UNIX for Dummies Questions & Answers

How to remove a string from a specific column in a file

Hello, A basic query. How can I remove a string from a specific column. For example, remove "abcd" just from column 2 in example file: abcd abcd1 abcd abcd2 abcd abcd3 to get output: abcd 1 abcd 2 abcd 3 Thank you!:) (4 Replies)
Discussion started by: auburn
4 Replies

5. Shell Programming and Scripting

Remove specific content in a file

Hi, I have a file called fl_list consists of files i have to archive. I want to create a exception parm called except_parm, so if it finds the directory it will not archive these files and remove from fl_list. $ cat fl_list /apps/dev/ihub/ready/IA003B/IA003B_Deal_Header_yyyymmdd_hhmmss.txt... (1 Reply)
Discussion started by: k9cheung
1 Replies

6. Shell Programming and Scripting

how can i remove comments in random positions in a file?(bash)

Suppose i have a file like this: #bla bla #bla bla bla bla bla Bla BLA BLA BLA #bla bla .... .... how can i remove all comments from every line,even if they are behind commands or strngs that are not comments? any idea how i could do that using awk? (2 Replies)
Discussion started by: bashuser2
2 Replies

7. Shell Programming and Scripting

how to remove specific lines from a file (reprise)

Hello, I've to change the shell in /etc/passwd for some users . I've the list of users but I'm not able to modify the file with scripting . I'm working on a Sol10 . Can anyone help me ? tnks (7 Replies)
Discussion started by: gogol_bordello
7 Replies

8. Shell Programming and Scripting

Remove duplicates from File from specific location

How can i remove the duplicate lines from a file, for example sample123456Sample testing123456testing XXXXX131323XXXXX YYYYY423432YYYYY fsdfdsf123456gsdfdsd all the duplicates from column 6-12 , must be deleted. I want to consider the first row, if same comes in the given range i want to... (1 Reply)
Discussion started by: gopikgunda
1 Replies

9. Shell Programming and Scripting

how to remove specific lines from a file

When restoring a file in my uninstall program I need to remove the lines I added to a file during the install. In between the file can be modified by the users. Assume file1 is as follow: xxx str2 xxxx ..... ...The Following lines containing str* have to be removed... xxx str1 xxxx xxx ... (17 Replies)
Discussion started by: bluemoon1
17 Replies

10. Shell Programming and Scripting

remove specific lines from a file

Hi there I have a file with a variable amount of rows but the 45th, 46th and 47th charachter of each line is the status field which is a three digit code ie 001, 002, 003 etc. My question is this..I need to strip all the records/lines with 002's out of the file completely and put them into... (14 Replies)
Discussion started by: hcclnoodles
14 Replies
Login or Register to Ask a Question