Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6925597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:48:36+00:00 2026-05-27T10:48:36+00:00

I need to extract the filename from a text file whereas the output on

  • 0

I need to extract the filename from a text file whereas the output on the text file doesn’t have fonts.

So as you can see from the output file below I need to print out results where they are no fonts after the first results? So only the last result has fonts in this output

Does this make sense – Would Grep, Sed or Awk be the answer

So need a output from the text file below that shows that no fonts are present in that PDf within the **START and **END

******************START***********************
name                                 type              emb sub uni object ID
------------------------------------ ----------------- --- --- --- ---------
/home/user1/Documents/temp1.pdf
******************END***********************
******************START***********************
name                                 type              emb sub uni object ID
------------------------------------ ----------------- --- --- --- ---------
/home/user1/Documents/temp2.pdf
******************END***********************
******************START***********************
name                                 type              emb sub uni object ID
------------------------------------ ----------------- --- --- --- ---------
BAAAAA+TimesNewRomanPS-BoldMT        TrueType          yes yes yes     14  0
CAAAAA+TimesNewRomanPSMT             TrueType          yes yes yes      9  0
/home/user3/Documents/temp file.pdf
******************END***********************
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:48:36+00:00Added an answer on May 27, 2026 at 10:48 am

    This prints any line containing “.pdf” if the previous line starts with -.

    [me@home]$ awk '{if (st && match($0,".pdf")){print $0}; st=match($0,"^-")}' in.txt
    /home/user1/Documents/temp1.pdf
    /home/user1/Documents/temp2.pdf
    

    It is not a generic solution, but will work with the input data you’ve given. I can imagine several edge cases where this might fail but it’s all down to the specifications of your input file.


    Update

    (Based on the script you’ve posted in the comments below) If what you’re trying to do is simply to identify PDF files that have no embedded fonts, this might work:

    MAGNUM="/mnt/network/User\ 1\ PDF\ 06.12.11/"
    has_no_fonts() {
        COUNT=$(pdffonts "$1" 2> /dev/null | wc -l)
        exit $(( $COUNT - 4 ))
    }
    export -f has_no_fonts
    find "$MAGNUM" -type f -name "*.pdf" -exec bash -c 'has_no_fonts "{}"' \; -print
    

    Here’s a breakdown of the script:

    • Detecting embedded font count. Would have been simple if pdffonts returned a specific value if no fonts were embedded but that is not so. We therefore count the number of output lines and deduct 2 (header lines) to determine the number of embedded fonts

      COUNT=$(pdffonts "$1" 2> /dev/null | wc -l) # number of output lines
                                                  # exactly 2 if no fonts
                                                  # exactly 0 if there are errors
      exit $(( $COUNT - 2 ))  # exit 0 (success) if and only if PDF has no fonts
      
    • bash function exported so it can be used in subshell.

      export -f has_no_fonts
      
    • Locate pdf files and only print out name if PDF valid and has no fonts

      find .....  -exec bash -c 'has_no_fonts "{}"' \; -print
                        -------                        -------
                            |                             |
                -exec cannot run bash functions     Will only print 
                 so run in a bash subshell       filename if prev command exit with 0
      

    If you prefer a one-line, the whole script can be written as:

    find "$MAGNUM" -name "*.pdf" \
        -exec bash -c 'exit $(($(pdffonts "{}" 2> /dev/null |wc -l) - 2))' \; -print
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a filename 10.10.10.17_super-micro-100-13.txt from which I need to extract everything between _
What I need to do is extract the filename from %%f so I can
I have a situation where I need to extract dates from the file names
I need to extract just the filename (no file extension) from the following path....
I need to extract the filename from a path (a string): e.g., C:\folder\folder\folder\file.txt =
Need to extract .co.uk urls from a file with lots of entries, some .com
I need to extract a value from a hidden HTML field, have somewhat figured
I need to extract the URL's from the php datas, how can i achieve
I have text being passed to a function. That text can contain anything, from
I need to be able to only extract the filename (info.txt) from a line

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.