I have a very basic shell script right now, and I am trying to run grep from inside of it. It looks like this:
The name of said file is "myscript" for right now. I am executing it on the command line as follows:
It SHOULD output the first three lines of the text file, since they are preceded with // style comments, which is what I am looking for. It should look like the following:
I know it should look like that because when I run
outside of the script, it displays. From inside the script, I get this error:
I'm not sure what I'm doing wrong... I also want to mention that when I put "test.txt" inside the script instead of "$filename", it runs perfectly, so I KNOW it has to be with the variable, but what is it that I messed up?
For added information, the primary shell is tcsh and the shell I am trying to run the script in is sh, if that makes a difference.
I call my bash shell script "test.sh" and pass "admin_usr.txt" as an argument like below.
./test.sh admin_usr.txt
Inside the "test.sh" i wish to check if the filename passed "admin_usr.txt" i.e "$1" contains the string "admin" or not ... which in this case it does.
Note: I do not wish to... (5 Replies)
There is a file name list_filenames.dat, this has all the list of all files I need to encrypt, I did not understand what the following syntax is doing:
grep -s "^$1" list_filenames.dat, when I manually run this command it just returns all the lines, what is the usage of this ? can someone... (4 Replies)
I am using a shell script in fedora linux. While calling to the shell I am also passing an argument (var1=0.77) like shown below
sh gossip.sh var1=0.77
in the shell following command is written (which doesn't work)
sed - i -e 's@prob=@prob="$var1";//@g' file.txt
Actually i want the... (7 Replies)
I want to print the filename
keyword="XXTNL_AVSKRIV2ING"
ftype="sql'
I wan to search the keyword in all the sql files and the output shoul dbe filename:count
grep -iwc "$keyword" *.$ftype | grep -v ":0$"
But the output does not dispaly the filename which contains space as... (4 Replies)
Hi,
Can anyone let me know what is difference between
grep .* foo.c
grep '.*' foo.c
I am not able to understand what is exact difference.
Thanks in advance (2 Replies)
Hi,
Below is starting entry of my script
#!/bin/ksh
Usage()
{
print "Usage: $0 ID OPTION SERVER"
print "<br>Where :"
print "<br>Enter your ID into PARAM1, OPTION in the PARAM2 and SERVER in the PARAM3 field"
print "<br>ID should be a valid ID"
print "<br>OPTION should be either... (2 Replies)
Hello, i'm fairly new to scripting, so please bear with me (I did try looking this up first, i figured it had to have been asked already).
#!/bin/bash
fileName=`date | sed -n 's/ /_/g p' | sed -n 's/^/Backup_/p' | sed -n 's/$/\.tar/p'`; #THIS SETS BACKUP_DATE
echo $fileName #TEST OF VALUE
... (4 Replies)
Anyone who can assist :
I am trying to pass the group vairiable to a filename:
rpt_tsavegrp=/export/legato/scripts/$group_savegrp_rpt.$dat
It will not pass to variable.
Anyone have any ideas what I am doing wrong here.
Thanks
# This script sends email that save group completed.... (3 Replies)
Hi,
Is it possible to accept a filename as command line parameter and then write to that file using command redirection? i tried the below script.
outputfile=`echo $1`
echo "Writing to file" > 'echo $outputfile'
exit $returncode
but it isnt working. is there any other way to... (9 Replies)
Hi,
I have a question on bash. Basically I would like to print a file name using bash. I am actually trying to grep a particular character in sequential files.
I have alot files such that a.txt, b.txt,c.txt...etc.
If I found a certain character, I would print that particular filename.
I... (5 Replies)