10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi Forum.
I have the following test.txt file and need to extract certain rows based on "starting position", "length of string" and "string to search for":
1a2b3d
2a3c4d
.....
My script accepts 3 parameters: (starting col pos, length to search for, string to search for) and would like to... (4 Replies)
Discussion started by: pchang
4 Replies
2. Shell Programming and Scripting
I wrote a very simple script to understand how to call user-defined functions from within awk after reading this post.
function my_func_local {
echo "In func $1"
}
export -f my_func_local
echo $1 | awk -F"/" '{for (k=1;k<=NF;k++) {
if ($k == "a" ) {
system("my_local_func $k")
}
else{... (19 Replies)
Discussion started by: sreyan32
19 Replies
3. Shell Programming and Scripting
Currently have this:
set current=192.168.0.5
set servicehost = `echo $current | awk -F. '{print $4}'`
echo $numberoffields
5
..but would like to reduce # of variables and eliminate echo to have something like this:
set servicehost = `awk -v s="$current" -F. 'BEGIN{print $2}'`But... (3 Replies)
Discussion started by: Mid Ocean
3 Replies
4. Shell Programming and Scripting
Hi,
I have the following gcov compilation flags in all the QT source code project (*.pro) files.
CONFIG(gcov) {
LIBS += -lgcov
QMAKE_CXXFLAGS += -fprofile-arcs -ftest-coverage
}
Now, I want to remove these flags off my files. Please help me with a script to... (1 Reply)
Discussion started by: royalibrahim
1 Replies
5. Shell Programming and Scripting
I have the following code in a csh script
I want to pass the value of the variable sigmasq to the awk script so that I can divide $0 by the value of sigmasq
grep "Rms Value" $f.log \
| awk '{ sub(/*:*\.*/,x); \
print... (2 Replies)
Discussion started by: kristinu
2 Replies
6. Shell Programming and Scripting
I'm very new to awk and sed and I've been struggling with this for a while.
I'm trying to search a file for a string with special characters and this string is a command line argument to a simple script.
./myscript "searchpattern" file
#!/bin/sh
awk "/$1/" $2 > dupelistfilter.txt
sed... (6 Replies)
Discussion started by: cue
6 Replies
7. Shell Programming and Scripting
I'm an experienced awk user, but this one has me stumped. I have an awk script which is called from a UNIX command line as you'd expect:
myscript.awk -v foo=$1 -v bar=$2 filename
My question is this: is there a mechanism for determining the names of the -v variables within a script?
... (3 Replies)
Discussion started by: John Mac
3 Replies
8. Shell Programming and Scripting
I have no idea how to make my own flags. (6 Replies)
Discussion started by: rcunn87
6 Replies
9. UNIX for Dummies Questions & Answers
Does anybody know how to print a variable passed to awk command?
awk -F"|" 'BEGIN {print $job,"\n","Question \n"} {print $1,$2$4," ",$3}' "job=$job1" file1
I am trying to pass job the variable job1.
the output is blank.
?? (3 Replies)
Discussion started by: whatisthis
3 Replies
10. UNIX for Dummies Questions & Answers
Anybody know what's wrong with this syntax?
awk -v job="$job" 'BEGIN { FS="|"}
{print $1,$2," ",$4," ",$3\n,$5,"\n"}' list
It's keeping give me this message:
awk: syntax error near line 1
awk: bailing out near line 1
It seems awk has problem with my BEGIN command.
Any... (8 Replies)
Discussion started by: whatisthis
8 Replies