08-08-2010
about an argument with variable in sed
hi all
let say I run the ./xxx.bash x x x x or ./xxx.bash x x x or ./xxx.bash x x x x x
the last argument always a filename
the last arugment filename format is 5-10-22.txt
my question is how can I put this arugment into variable and I can use it in sed or any other way that i can use
I have tried use the following commands but not work
var=$#
sed -n '/xxxxx/p' \$$var > xxx
thank all
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I am new to unix. Is their a way to pass the output of the line below to a variable var1.
ls -1t | head -1.
I am trying something like var1=ls -1t | head -1, but I get error.
Situation is: I get file everyday through FTP in my unix box. I have to write a script that picks up first... (1 Reply)
Discussion started by: rkumar28
1 Replies
2. Shell Programming and Scripting
Hello,
I have a file like
was123##abcdefg abddef
was123##xuzaghg agdfgg
was133##CGHAKS DKGJG
from the file i need to print the line after ## where the serach value is passed by an env variable called luster (which is currently set to was123):
i tried using the below code but it... (7 Replies)
Discussion started by: amit1_x
7 Replies
3. Shell Programming and Scripting
I have a script file. test.sh
I am running it by command
sh test.sh 10102004
where 10102004 is the script argument.
I wan to assign this 10102004 to a variable.
How can i do this?
I tried &1 and awks ARGV its not working :( (2 Replies)
Discussion started by: rohankit
2 Replies
4. Shell Programming and Scripting
Hi,
I had written a shell script to pass command line argument to variable in a function.
Here is my code:
main
if ; then
.$1
echo $1
get_input_file
else
echo "input file $1 is not available"
fi
get_input_file()
{
FILE = "$1"
echo $FILE
} (10 Replies)
Discussion started by: Poonamol
10 Replies
5. Shell Programming and Scripting
Gooday
I have an argument string that contains 15 arguments.
The first 14 arguments are easy to handle because they are separated by spaces
ARG14=`echo ${ARGSTRING} | awk '{print $14}'`
The last argument is a text that may be empty or contain spaces. So any ideas on how I get the last... (23 Replies)
Discussion started by: zagga
23 Replies
6. Shell Programming and Scripting
I am trying to get the details of iowait for last hour using sar. When I give date as argument it works.
# sar -u -s 22:24:00 -e 23:24:00
Linux 2.6.35.13-26 (XX.server.com) 04/11/2012
10:30:03 PM CPU %user %nice %system %iowait %idle
10:40:04 PM all 5.03 ... (2 Replies)
Discussion started by: anil510
2 Replies
7. Programming
Hi,
In directory "inoutfiles", I have folders fold0001, fold0002 and so on. Every folder has corresponding file file0001.txt, file0002.txt and so on. I want to perform a certain action on multiple files in one go. The cpp file is in the same directory as "inoutfiles".
This is my code :
... (1 Reply)
Discussion started by: KidD312
1 Replies
8. Shell Programming and Scripting
I have a script.
#!/bin/sh
cur_$1_modify_time=Hello
echo "cur_$1_modify_time"
When I run like
sh /root/script1 jj
I expect value "Hello" being assigned to variable "cur_jj_modify_time" and output being "Hello" ie echoing $cur_jj_modify_time
But the output comes as
# sh... (3 Replies)
Discussion started by: anil510
3 Replies
9. Shell Programming and Scripting
Hi,
I am trying to pass a variable as an argument to another script. While substitution of variable, I am facing a problem.
varaiable "a" value should be -b "FPT MAIN".
When we pass "a" to another script, we are expecing it to get substitue as ./test.sh -b "FPT MAIN". But, it is getting... (9 Replies)
Discussion started by: Manasa Pradeep
9 Replies
10. Shell Programming and Scripting
I want to send the content of a bash variable as a python argument for processing. The problem is that bash doesn't "expand" the content, just sends the expression.
script.sh#!/bin/bash
export RECEIVEDDATE=$(date +"%Y%m%d.%H%M%S")
perl checkdate.py
checkdate.pyimport datetime
import os... (3 Replies)
Discussion started by: Tribe
3 Replies