1

I received a zip file with a folder structure that include parenthesis. I've worked through two processes at the cli and now merge them into a script

The first searches through the file structure for specific files correcting the parenthesis then pipes to tshark to process. my output using sed works at the stoud but the pipe tshark doesn't like the path I'm throwing.

find <path> -iname *.cap |sed 's/(/\\(/' |sed 's/)/\\)/'

takes folder/folder(description)/file.cap results in folder/folder(description)/file.cap cool!

when I add this to a bash script

#/BIN/BASH

capfiles=($(find <path> -iname *.cap | sed ’s/(/\\(/‘ |sed ’s/)/\\)/‘))

for i in “${capfiles[@]}”;do
     tshark -r $i -T fields -e dns.qry.name |sort u > $i.uniquefqdns2lookup.txt

done

I get

'tshark: The file "folder/folder\(description\)/file.cap" doesn't exist.
'tshark: The file folder/folder\(description\)/file.cap" doesn't exist.
'tshark: The file folder/folder\(description\)/file.cap" doesn't exist. 

I've tried playing with ./ in the patch as an explicit character with no luck. that output looks like:

'tshark: The file "./"folder/folder\(description\)/file.cap" doesn't exist.
'tshark: The file "./folder/folder\(description\)/file.cap" doesn't exist.
'tshark: The file "./folder/folder\(description\)/file.cap" doesn't exist. 

What am I missing? Am i totally off with this?

  • change #/BIN/BASH to #!/bin/bash. – αғsнιη Dec 23 '14 at 15:40
0

In addition to KasiyA's comment,

  • Make sure your quotes are the right way. In your question, the sed patterns are shown ending with a backquote (`) rather than a forward quote ('). I don't know if that's actually the case in your script.
  • Put the $i in double quotes ("$i") (see this answer).
  • You may not actually need the backslashes, depending on tshark's settings. Using "$i" will preserve the parentheses in your filename. Tshark is probably looking for a file with the literal \ in the name. Try

    capfiles=($(find <path> -iname *.cap )
    

and see what you get.

  • I had to add another bracket at the end but here is my output (no change) “tcpdumps/tcpdumpLog(something)/traffic.cap tcpdumps/tcpdumpLog(something)/traffic.cap tcpdumps/tcpdumpLog(something)/traffic.cap tcpdumps/tcpdumpLog(something)/traffic.cap tcpdumps/tcpdumpLog(something)/traffic.cap” where do the leading and tailing double quotes come from? – carter Dec 23 '14 at 22:37
  • Think I answered my own question – carter Dec 23 '14 at 22:41
  • Think I answered my own question about the double quotes. That had no effect on the original issue. – carter Dec 23 '14 at 22:47
  • @carter so what did the problem turn out to be? Please post and accept your own answer if necessary so the question won't be on the "unanswered" list. Thanks! – cxw Dec 28 '14 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.