2

I am retrieving information with the following command:

EXP=$(curl "https://www.ebi.ac.uk/ena/data/warehouse/filereport?accession=ERR146982&result=read_run&fields=study_accession" 2>/dev/null| tail -n 1)
DESC=$(curl "https://www.ebi.ac.uk/ena/data/view/${EXP}&display=xml" 2>/dev/null | grep "<DESCRIPTION>" | sed 's/     <DESCRIPTION>//g' | sed 's/<\/DESCRIPTION>//g')
printf "$line\t$DESC\n"

However, I get the error printf: ')': invalid format character and the output (shortened here) ERR146988 Background: Observations that the airway microbiome is disturbed [...] Streptococcus being the most common genus (49.72

How do I correctly use printf in combination with variables, that can basically take every possible value including special characters?

Desired output:

ERR2319455    The American Gut project is the largest crowdsourced citizen science project to date. Fecal, oral, skin, and other body site samples collected from thousands of participants represent the largest human microbiome cohort in existence. Detailed health and lifestyle and diet data associated with each sample is enabling us to deeply examine associations between the human microbiome and factors such as diet (from vegan to near carnivore and everything in between), season, amount of sleep, and disease states such as IBD, diabetes, or autism spectrum disorder-as well as many other factors not listed here. The American Gut project also encompasses the British Gut and Australian Gut projects, widening the cohort beyond North America. As the project continues to grow, we will be able to identify significant associations that would not be possible with smaller, geographically and health/disease status-limited cohorts.
1
  • Pass the arguments in the second parameter: printf <FORMAT> <ARGUMENTS...> Commented Aug 12, 2018 at 12:01

1 Answer 1

1

You want:

printf "$line\t%s\n" "${DESC}"

Check

help printf

Btw, if you have xmllint installed, you can get the description more nicely with xpath:

curl "https://www.ebi.ac.uk/ena/data/view/${EXP}&display=xml" \
  | xmllint --xpath '//DESCRIPTION/text()' -
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.