cut or nawk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting cut or nawk
# 8  
Old 07-24-2012
OK. Will you try like this?
Code:
nawk '/busti/ && match($8,/\/[^\/]*\/[^\/]*\/[^\/]*\/[^\/]*\/[^\/]*/) {print substr($8,RSTART,RLENGTH)}' ruta.txt

# 9  
Old 07-24-2012
Code:
 
bash-3.2$ cat b.txt
/SERVER01-01/=user/a3/85/=USER1
/SERVER01-01/=user/a3/85/=USER1/=+Eliminats
/SERVER01-01/=user/a3/85/=USER1/=+Enviats
/SERVER01-01/=user/a3/85/=USER1/=+Esborranys
/SERVER01-02/=user/c6/30/=USER2
/SERVER01-02/=user/c6/30/=USER2/=+Eliminats
/SERVER01-02/=user/c6/30/=USER2/=+Enviats
/SERVER01-02/=user/c6/30/=USER2/=+Esborranys
/SERVER01-02/=user/84/60/=USER3
/SERVER01-02/=user/84/60/=USER3/=+Eliminats
/SERVER01-02/=user/84/60/=USER3/=+Enviats
/SERVER01-02/=user/84/60/=USER3/=+Esborranys

bash-3.2$ nawk '{n=split($1,a,"/");if(n==6)print $1}' b.txt
/SERVER01-01/=user/a3/85/=USER1
/SERVER01-02/=user/c6/30/=USER2
/SERVER01-02/=user/84/60/=USER3

Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using :<<cut / cut to comment out block of bash script

I am using : << cut / cut to comment out block of code. Works fine on few lines of script, then it gives me this cryptic error when I try to comment out about 80 lines. The "warning " is at last line of script. done < results 169 echo "END read all positioning parameters" 170... (8 Replies)
Discussion started by: annacreek
8 Replies

2. UNIX for Beginners Questions & Answers

Cut command: can't make it cut fields

I'm a complete beginner in UNIX (and not a computer science student either), just undergoing a tutoring course. Trying to replicate the instructions on my own I directed output of the ls listing command (lists all files of my home directory ) to My_dir.tsv file (see the screenshot) to make use of... (9 Replies)
Discussion started by: scrutinizerix
9 Replies

3. Shell Programming and Scripting

Nawk Problem - nawk out of space in tostring on

Hi.. i am running nawk scripts on solaris system to get records of file1 not in file2 and find duplicate records in a while with the following scripts -compare nawk 'NR==FNR{a++;next;} !a {print"line"FNR $0}' file1 file2duplicate - nawk '{a++}END{for(i in a){if(a-1)print i,a}}' file1in the middle... (12 Replies)
Discussion started by: Abhiraj Singh
12 Replies

4. Shell Programming and Scripting

Cut Command error cut: Bad range

Hi Can anyone what I am doing wrong while using cut command. for f in *.log do logfilename=$f Log "Log file Name: $logfilename" logfile1=`basename $logfilename .log` flength=${#logfile1} Log "file length $flength" from_length=$(($flength - 15)) Log "from... (2 Replies)
Discussion started by: dgmm
2 Replies

5. Shell Programming and Scripting

Nesting - two nawk into one nawk

hi people; this is my two awk code: nawk '/cell+-/{r=(NF==8) ? $4FS$5FS$6 : NF==7 ? $4FS$5 : $4 ;c=split(r,rr);for (i=1;i<=c;i++){if(rr != "111111"){printf($3" %d ""\n",(i+3))}}printf("")}' /home/gc_sw/str.txt > /home/gc_sw/predwn.txt nawk -F'*' '{gsub(/ *$/,"")}$0=$1$($NF-2)'... (2 Replies)
Discussion started by: gc_sw
2 Replies

6. Shell Programming and Scripting

how to access values of awk/nawk variables outside the awk/nawk block?

i'm new to shell scripting and have a problem please help me in the script i have a nawk block which has a variable count nawk{ . . . count=count+1 print count } now i want to access the value of the count variable outside the awk block,like.. s=`expr count / m` (m is... (5 Replies)
Discussion started by: saniya
5 Replies
Login or Register to Ask a Question