answersLogoWhite

0


Best Answer

Use the 'sed' command - it looks for a pattern and then you can 'delete' the line by preventing the input line from going to the output (sed is a filter program). For example,

sed -e '/word/d' file1 file2 file3 > file.out

will remove any line containing the word 'word' from the three files by not copying it to the output file 'file.out'

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

#!/bin/csh

grep -v $argv[1] $argv[2]

arguments can be any word which is to be deleted except commands.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Shell script that deletes all lines containing a specific word in one or more files?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Can you execute a shell script if you do not have read permission for the file containing the script?

No, the shell needs both execute and read permissions to run the script.


Write a shell script which deletes all line containing the word unix in the filesn suppiled as argument to this shell script?

# SS29 # Script to delete all lines containing the word 'unix' from files supplied as arguments # Usage: SS29 file1 file2 file3 ... if [$# -lt 2] then echo Insufficient arguments exit fi for file do grep -v unix $file>/temp/$file cp /temp/$file $file done


What are the two ways you can execute a shell script when you do not have execute access permission for the file containing the script?

To do this you will need at least read permission; if you don't have that then you will not be able to execute the script at all. One way is to copy the script to your directory and add the execute permission. The second way is to call the correct shell interpreter program directly, as in: ksh /some/file/shell


What is the command to execute a shell script?

If the shell script is readable and executable then to execute it just type the name of the shell script file. Otherwise, you can explicity call a shell interpreter to run the file as a shell script, i.e., ksh myfile


What command in a script would print on the screen the first variable past to that script?

Well the question is not particularly specific. I assume that we are talking about shell and in this example I would refer to "bash" shell. #!/bin/bash echo $1 this simple script will print first parameter passed to it.


What is electronic shells?

A shell surrounding the nucleus of an atom containing electrons.


Write a shell script to show that user is logged in or not?

You don't need a shell script for that; use either 'whoami' or 'id'


How do you read from file in unix shell script?

You will have to be more specific about what you intend to do. In general, a shell script by itself does not read file information and then do something with it. There may be calls to other scripting languages such as awk, perl, python, etc., that will actually read the information and process the data.


Parse log files-shell script?

There are following shell scripts available at the below mentioned url -1. Shell Script for Log4j Log Analysis and exception reporting2. Log Monitoring Shell Script - email upon errorsHope that's what you are looking for.


What is the Purpose of exit command in Shell of Unix?

The 'exit' command allows you to stop a running shell script at any point and to return a "status" value back to whomever called the shell script. This is a very common practice with shell scripts; sometimes you want to stop the script before it gets to the end of the shell script (for various logic reasons). The 'exit' command also allows you to give a status that any other calling process can use to determine if the shell script ended successfully or not.


How do you compile and run shell script of factorial?

Shell scripts are not compiled; they are interpreted (and therefore do not need to be compiled). Just type in the name of the shell script and any parameters it needs to execute.


How do you write a shell script which counts the last 10 lines present in a given file?

You don't need a shell script to do this - just use the 'tail' command.