Skip to main content
added 18 characters in body
Source Link
muru
  • 77.9k
  • 16
  • 212
  • 318

I am using a Bash script to use awk to look for this: (0010,0080) The awk will generally look for any numeric value seperated by a comma in between parenthesis. I have done everything I can think of and still can't get ANY results when I append it to a text file). My regex is:

awk '/\([0-9]{4},[0-9]{4}\)/' dcmResults.txt >> ~/export/"$1"/tagResults.txt

I have done almost every variation of using an escape character for the parenthesis including not using any and I get NO results when appending to a text file. Can someone please tell me what I am doing wrong?

UPDATE, here is what the whole script looks like:

#!/bin/bash
echo "Enter SUID: "
read uid
echo "Enter Tag Number: "
read dicomTag

dicomDump() {
        arg1=$1
        cd ~/export/"$1"
        dcmdump *.dcm > ~/export/"$1"/dcmResults.txt
}
tagFinder() {
        arg1=$1
        arg2=$2
        for i in $(cat ~/export/"$1"/dcmResults.txt); do 
            grep "$2" | awk '/[0-9]{4},[0-9]{4}.*/' dcmResults.txt >> ~/export/"$1"/tagResults.txt
        break
done;
}
dicomDump "$uid"
tagFinder "$uid" "$dicomTag"

I am using a Bash script to use awk to look for this: (0010,0080) The awk will generally look for any numeric value seperated by a comma in between parenthesis. I have done everything I can think of and still can't get ANY results when I append it to a text file). My regex is:

awk '/\([0-9]{4},[0-9]{4}\)/' dcmResults.txt >> ~/export/"$1"/tagResults.txt

I have done almost every variation of using an escape character for the parenthesis including not using any and I get NO results when appending to a text file. Can someone please tell me what I am doing wrong?

UPDATE, here is what the whole script looks like:

#!/bin/bash
echo "Enter SUID: "
read uid
echo "Enter Tag Number: "
read dicomTag

dicomDump() {
        arg1=$1
        cd ~/export/"$1"
        dcmdump *.dcm > ~/export/"$1"/dcmResults.txt
}
tagFinder() {
        arg1=$1
        arg2=$2
        for i in $(cat ~/export/"$1"/dcmResults.txt); do grep "$2" | awk '/[0-9]{4},[0-9]{4}.*/' dcmResults.txt >> ~/export/"$1"/tagResults.txt
        break
done;
}
dicomDump "$uid"
tagFinder "$uid" "$dicomTag"

I am using a Bash script to use awk to look for this: (0010,0080) The awk will generally look for any numeric value seperated by a comma in between parenthesis. I have done everything I can think of and still can't get ANY results when I append it to a text file). My regex is:

awk '/\([0-9]{4},[0-9]{4}\)/' dcmResults.txt >> ~/export/"$1"/tagResults.txt

I have done almost every variation of using an escape character for the parenthesis including not using any and I get NO results when appending to a text file. Can someone please tell me what I am doing wrong?

UPDATE, here is what the whole script looks like:

#!/bin/bash
echo "Enter SUID: "
read uid
echo "Enter Tag Number: "
read dicomTag

dicomDump() {
        arg1=$1
        cd ~/export/"$1"
        dcmdump *.dcm > ~/export/"$1"/dcmResults.txt
}
tagFinder() {
        arg1=$1
        arg2=$2
        for i in $(cat ~/export/"$1"/dcmResults.txt); do 
            grep "$2" | awk '/[0-9]{4},[0-9]{4}.*/' dcmResults.txt >> ~/export/"$1"/tagResults.txt
        break
done;
}
dicomDump "$uid"
tagFinder "$uid" "$dicomTag"
added 605 characters in body
Source Link
ryekayo
  • 4.8k
  • 10
  • 46
  • 67

I am using a Bash script to use awk to look for this: (0010,0080) The awk will generally look for any numeric value seperated by a comma in between parenthesis. I have done everything I can think of and still can't get ANY results when I append it to a text file). My regex is:

awk '/\([0-9]{4},[0-9]{4}\)/' dcmResults.txt >> ~/export/"$1"/tagResults.txt

I have done almost every variation of using an escape character for the parenthesis including not using any and I get NO results when appending to a text file. Can someone please tell me what I am doing wrong?

UPDATE, here is what the whole script looks like:

#!/bin/bash
echo "Enter SUID: "
read uid
echo "Enter Tag Number: "
read dicomTag

dicomDump() {
        arg1=$1
        cd ~/export/"$1"
        dcmdump *.dcm > ~/export/"$1"/dcmResults.txt
}
tagFinder() {
        arg1=$1
        arg2=$2
        for i in $(cat ~/export/"$1"/dcmResults.txt); do grep "$2" | awk '/[0-9]{4},[0-9]{4}.*/' dcmResults.txt >> ~/export/"$1"/tagResults.txt
        break
done;
}
dicomDump "$uid"
tagFinder "$uid" "$dicomTag"

I am using a Bash script to use awk to look for this: (0010,0080) The awk will generally look for any numeric value seperated by a comma in between parenthesis. I have done everything I can think of and still can't get ANY results when I append it to a text file). My regex is:

awk '/\([0-9]{4},[0-9]{4}\)/' dcmResults.txt >> ~/export/"$1"/tagResults.txt

I have done almost every variation of using an escape character for the parenthesis including not using any and I get NO results when appending to a text file. Can someone please tell me what I am doing wrong?

I am using a Bash script to use awk to look for this: (0010,0080) The awk will generally look for any numeric value seperated by a comma in between parenthesis. I have done everything I can think of and still can't get ANY results when I append it to a text file). My regex is:

awk '/\([0-9]{4},[0-9]{4}\)/' dcmResults.txt >> ~/export/"$1"/tagResults.txt

I have done almost every variation of using an escape character for the parenthesis including not using any and I get NO results when appending to a text file. Can someone please tell me what I am doing wrong?

UPDATE, here is what the whole script looks like:

#!/bin/bash
echo "Enter SUID: "
read uid
echo "Enter Tag Number: "
read dicomTag

dicomDump() {
        arg1=$1
        cd ~/export/"$1"
        dcmdump *.dcm > ~/export/"$1"/dcmResults.txt
}
tagFinder() {
        arg1=$1
        arg2=$2
        for i in $(cat ~/export/"$1"/dcmResults.txt); do grep "$2" | awk '/[0-9]{4},[0-9]{4}.*/' dcmResults.txt >> ~/export/"$1"/tagResults.txt
        break
done;
}
dicomDump "$uid"
tagFinder "$uid" "$dicomTag"
Source Link
ryekayo
  • 4.8k
  • 10
  • 46
  • 67

Regex gone Wrong

I am using a Bash script to use awk to look for this: (0010,0080) The awk will generally look for any numeric value seperated by a comma in between parenthesis. I have done everything I can think of and still can't get ANY results when I append it to a text file). My regex is:

awk '/\([0-9]{4},[0-9]{4}\)/' dcmResults.txt >> ~/export/"$1"/tagResults.txt

I have done almost every variation of using an escape character for the parenthesis including not using any and I get NO results when appending to a text file. Can someone please tell me what I am doing wrong?