shell script: File Manipulation
hi,everyone!i want write a shell script which can delete certain line in a file based on the user's selection.
user will give the string pattern in command line and the shell script will delete any matched lines in a file.i tried to use 'sed' to achieve this,however sed command considers the '$1' is a string pattern rather than a varaible. it will search the file with string pattern '$1'. thanks a lot for any helps! |
Hi,
Something like this ... Code:
#!/bin/bash |
Quote:
Code:
stuff=`grep -n "$info" $file | cut -d: -f1` Code:
sed "/$1/d" file |
All times are GMT -5. The time now is 06:18 AM. |