![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help needed in shell scripting | himvat | Shell Programming and Scripting | 3 | 11-16-2008 02:49 PM |
| Help needed - ksh shell scripting | subbu | Shell Programming and Scripting | 5 | 02-15-2008 12:53 PM |
| SHell Scripting Help Needed | cskumar | Shell Programming and Scripting | 2 | 07-17-2006 02:55 AM |
| Help needed - shell scripting | garric | Shell Programming and Scripting | 8 | 05-23-2006 07:08 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
sed/shell scripting - add line if needed and not allready there
I am writing a shell script that checks all .c files to see if they use fprintf or printf. If a file does, then the line #include <stdio.h> is added to the top of the file, unless it's already there. This is what I've got: Code:
#!/bin/sh egrep -l f?printf *.c | while read file; do sed -i '1i\ #include <stdio.h>' $file; done The problem is that it doesn't check to see if <stio.h> is allready there, so I've been thinking about using Code:
egrep -l f?printf *.c | grep -L '#include <stdio.h> but this doesn't work because it anonimizes the files when I use the pipe. Last edited by computethis; 4 Weeks Ago at 03:07 AM.. Reason: added code tags |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|