Relative Content

Tag Archive for awk

print lines from its beginning to selected characters

i want to print lines from its beginning to selected characters.
example:
a/b/i/c/f/d
a/e/b/f/r/c
a/f/d/g
a/n/m/o
a/o/p/d/l
a/b/c/d/e
a/c/e/v
a/d/l/k/f
a/e/f/c
a/n/d/c
./hhh.csh 03_input.txt c
Output:
a/b/i/c
a/e/b/f/r/c
a/b/c
a/c
a/e/f/c
a/n/d/c
i use this code but in codition $i ==a i don’t see the values ​​being checked against the a value i assigned
awk’
BEGIN{
ARGC=2
first = ARGV[2]
}
{
for(i=1;i<=NF;++i){
arr[i]=$i
if($i == “c”){
print arr[i]
}
}
}’ “$1” “$2”
print lines from its beginning to selected characters.
thanks for your support