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 7873929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:39:28+00:00 2026-06-03T02:39:28+00:00

I need to be able to copy a text file to another location and

  • 0

I need to be able to copy a text file to another location and then delete the contents of this text file (without deleting the file).

At the moment I am doing this:

#!/bin/bash

count=0

    for filename in `find . -name "*_list" -print`
    do
      while read -r line
      do
        echo $line 
        sync
        echo "### Trace Info ###" > log.txt
        sync
        python worker.py "$line"
        echo $line > traces/trace$count.txt
        sync
        sync
        sleep 1
        sync
        sync
        cp log.txt traces/trace$count.txt
        #cp log.txt traces/log.txt
        sync
        sleep 1
        count=$((count+1))
      done < $filename
    done

But calling sync and sleep it not working for me, instead I get file like this:
(NOTE: the python file is not writing to log.txt CacheGrind is.)

CachegrindMemMod/vg-in-place --tool=cachegrind --trace-children=yes /usr/sbin/mysqld 2>log.txt

cat trace10.txt | xxd
0000000: 2323 2320 5472 6163 6520 496e 666f 2023  ### Trace Info #
0000010: 2323 0a00 0000 0000 0000 0000 0000 0000  ##..............
0000020: 0000 0000 0000 0000 0000 0000 0000 0000  ................
0000030: 0000 0000 0000 0000 0000 0000 0000 0000  ................
0000040: 0000 0000 0000 0000 0000 0000 0000 0000  ................
0000050: 0000 0000 0000 0000 0000 0000 0000 0000  ................
0000060: 0000 0000 0000 0000 0000 0000 0000 0000  ................
0000070: 0000 0000 0000 0000 0000 0000 0000 0000  ................
0000080: 0000 0000 0000 0000 0000 0000 0000 0000  ................
0000090: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000a0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000b0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000c0: 0000 0000 0000 0000 0000 0000 0000 0000  ................

This trace has 4 megs of zeros which should have been text.

ls -la trace10.txt 
-rw-r--r-- 1 root root 4350121 2012-04-29 15:34 trace10.txt

I am guessing there is some caching going on that is preventing me from being able to get the accrual text. Any ideas would be great.

If you are interested the file should contain a list of memory addresses retrieved from a modified version of CacheGrind that looks like this:

Dw: 0x4916e30
Dw: 0x4916df0
Dw: 0x4916db0
Dw: 0x4916d70
Dr: 0x4916d30
Dr: 0x4916cf0
Dr: 0x4916cb0
Dr: 0x4916c70
Dr: 0x4916c30
Dr: 0x4916bf0
Dr: 0x4916bb0
Dr: 0x4916b70
Dr: 0x4916b30
Dr: 0x4916af0
Dr: 0x4916ab0

Also modified version of CacheGrind can be found here

Additional Info:
I noticed some file only contain the header and no null data. This also leads me to think its an I/O caching problem

  • 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-06-03T02:39:30+00:00Added an answer on June 3, 2026 at 2:39 am

    Who’s writing in that log.txt file? The python script? Is it working in the background? If so, why are trying to copy the (not completed) file? Why are you trying to sync in the bash script?

    • Extend the script so it allows the log file as a command line parameter, so each invocation is going to write to a separate file.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to be able to copy a file that exists on the target
We are able copy to clipboard changeset of our activities. But often we need
I need to repeatedly copy text from a fixed size rectangular region and I'd
I want to be able to open a PowerPoint file with PHP and copy
Users of the website need to able to store images in their area ,
Need to be able to pull Magento products into an external template. Need to
I need to be able to disable the selection of future dates within the
I need to be able to scroll a RichTextBox to the bottom, even when
I need to be able to take EPS and PDF's and convert them to
I need to be able to tell if a link (URL) points to an

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.