10 More Discussions You Might Find Interesting
1. Red Hat
num=10
sed -n '$num p' test.txt
sed -n '10 p' test.txt works
however i am putting the sed command in a loop and the line number is not static
Can someone please help me how to achive this. (1 Reply)
Discussion started by: figure20012
1 Replies
2. Red Hat
Hi all,
Hereby wish to have your advise for below:
Main concept is
I intend to get current directory of my script file.
This script file will be copied to /etc/init.d.
A string in this copy will be replaced with current directory value.
Below is original script file:
... (6 Replies)
Discussion started by: cielle
6 Replies
3. Shell Programming and Scripting
Does anyone know of a way to do something similar to this with awk and kill? I want to create the variable in awk and pass that variable to kill.
ps -ef | grep -i chromium | awk '{$2=x}' | kill -9 $x 2>/dev/null (9 Replies)
Discussion started by: cokedude
9 Replies
4. Shell Programming and Scripting
I'm trying to store the response from a nawk command inside of a ksh script. The command is:
text=$(nawk -F: '$1 ~ /${imgArray}/ {print $2}' ${etcDir}/captions.txt)
From what I can tell, the imgArray variable is not being expanding when it is inside the single quote ('). Is there something I... (4 Replies)
Discussion started by: meman1188
4 Replies
5. Shell Programming and Scripting
Hello,
I'd like to pass a variable to a sed command in a perl script. The script is like this :
#!/usr/bin/perl -w
$newline="new";
system q(sed '/insert/ i\ '$newline <sed1.txt >sed2.txt);
But the interpretor wouldn't recognize $newline, it inserts a "\n" instead.
I've also... (4 Replies)
Discussion started by: hi_ryo
4 Replies
6. Shell Programming and Scripting
Hi, Thanks for looking,,,,
(kornshell)
tmp3 is a list of line numbers
I want to print the lines from my list
code:
while read j
do
echo $j #works fine
echo $filename #works fine
#sed "'$jp'" "$filename" ... (7 Replies)
Discussion started by: JohnMario
7 Replies
7. UNIX for Dummies Questions & Answers
I have an awk statement where I Need to pass an environment variable but I cannot get it to work:
My evironment varible examples below:
$FILE1=/dev/fs/file.new
$FILE2=/dev/fs/file.old
Code below:
awk -F"|" '
BEGIN {
while( getline < "$FILE1" )
{ arr=1 }
}
arr != 1 { print }
'... (12 Replies)
Discussion started by: eja
12 Replies
8. Shell Programming and Scripting
I am trying to pass 2 shell variable's ("START" and "END") define earlier in the script to this awk statement, but i can't seem to pass it on. PLs help.
set START = xxxx
set END = yyyy
set selected_file = `awk '/$START/,/$END/' filename` (24 Replies)
Discussion started by: Raynon
24 Replies
9. UNIX for Dummies Questions & Answers
i would like to pass a variable to awk wherein the variable comes from external loop.
i tried this...
let x=0
until test $x -eq 32
do
cat file | awk '{ print $1 , "Number" , $($x) }' >> output
done
thanks, (4 Replies)
Discussion started by: inquirer
4 Replies
10. Shell Programming and Scripting
Hi there. If variables are named inside of a ksh script, how is it possible to pass these to sed?
The affected portion of my script goes something like this:
A=`cut -d. -f1 $FILE`
B=`cut -d. -f2 $FILE`
C=`cut -d. -f3 $FILE`
sed 's/1111/$A/g;s/2222/$B/g;s/3333/$C/g' file > anotherfile
... (2 Replies)
Discussion started by: kristy
2 Replies