Question

Hello What I need is a script to delete all files from the month and leave...

Hello

What I need is a script to delete all files from the month and leave only one ( the final one ) It will be marked as _final. The idea behind it:

In a Sharepoint site - in a document library - we are having to many files named

BTL_STOCK28732846

BTL_STOCK2873284fd

BTL_STOCK287328464

BTL_STOCK28732867u

and so one... exported from a software tool that we are using. So we do not need all those files but one. And this will be per month. So the script need to connect to office 365 , search in the rights Document library and sort the files. Then when find file starting with BTL_STOCK but ended with ..._final   to excluded (leave it in the folder). The rest starting with BTS_STOCK -be deleted. I will add it in task schedule then and will run once a month and delete all files by name but leave for every month _final one.

Homework Answers

Answer #1

Let us consider Documents directory contains the below files

$cd Documents

$ ls -lrt

BTL_STOCK28732846

BTL_STOCK2873284fd

BTL_STOCK287328464

BTL_STOCK28732867u

BTL_STOCK_final

Now we need to sort the files

$find /Documents -type f -exec sort -o {} {} > file.txt ---- , this command first searches for documents directory and performs/executes sort
on all files present in that directory and redirects the output to file.txt

Now we need to delete all files except the file which contains "final" in it's name

This can be done with :

sed '/final/!d' file.txt ---don't delete the file containing final in file.txt

Now file.txt contains only the file with "BTL_STOCK_final"

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Hello, I need a summary of the article below. Thanks It is only natural for moms...
Hello, I need a summary of the article below. Thanks It is only natural for moms to wonder if they are doing a good job as a mom? Constantly we wonder things like “how to be a good mom?” and “Am I a good mom?” All moms struggle with the question of whether she is doing a good mom and doing a good job as a mother. It’s only natural to worry about our children. And whenever one of them...
IN JAVA Iterative Linear Search, Recursive Binary Search, and Recursive Selection Sort: <-- (I need the...
IN JAVA Iterative Linear Search, Recursive Binary Search, and Recursive Selection Sort: <-- (I need the code to be written with these) I need Class river, Class CTRiver and Class Driver with comments so I can learn and better understand the code I also need a UML Diagram HELP Please! Class River describes river’s name and its length in miles. It provides accessor methods (getters) for both variables, toString() method that returns String representation of the river, and method isLong()...
Write a 4-6 sentence summary explaining how you can use STL templates to create real world...
Write a 4-6 sentence summary explaining how you can use STL templates to create real world applications. In your summary, provide an example of a software project that you can create using STL templates and provide a brief explanation of the STL templates you will use to create this project. After that you will implement the software project you described . Your application must be a unique project and must incorporate the use of an STL container and/or iterator and...
I quit social media for 1 month -- it was the best choice I ever made...
I quit social media for 1 month -- it was the best choice I ever made I quit social media for a month. So, I quit Facebook, Instagram, Snapchat, and Twitter. I just needed a break. It was time to cut myself off I stopped using social media this morning and my brain is going crazy. I just realised how often I glance down just to see if I have a notification. When I wake up in the morning, on...
I need the actual code for this... I found a similar response but it was not...
I need the actual code for this... I found a similar response but it was not thorough enough. Problem Prerequisites: None Suppose that a scientist is doing some important research work that requires her to use rabbits in her experiments. She starts out with one adult male rabbit and one adult female rabbit. At the end of each month, a pair of adult rabbits produces one pair of offspring, a male and a female. These new offspring will take one...
"All right. I need everyone in the conference room. Now!" said Celia, the communication supervisor at...
"All right. I need everyone in the conference room. Now!" said Celia, the communication supervisor at Protagoras, shouting across her department's cubicles. "What do you think this is all about?" Krystal asked of Jasper after catching his glance. "I have no idea, but I'm sure somehow it'll end in me doing more work," Jasper said sardonically. As Jasper and Krystal strolled into the conference room, Alexander and Ariel were already taking their seats around the mahogany conference table, where everyone...
Can someone please edit my code so that it satisfies the assignments' requirements? I pasted the...
Can someone please edit my code so that it satisfies the assignments' requirements? I pasted the codes below. Requirement: Goals for This Project:  Using class to model Abstract Data Type  OOP-Data Encapsulation You are asked to write an app to keep track of a relatively small music library. The app should load song information from a data file once the app is started. It should allow user to view, add, remove, and search for songs. The app should...
**This is the full question, but I only need the Contribution Margin, Sales Mix and Target...
**This is the full question, but I only need the Contribution Margin, Sales Mix and Target Profit. Cover-to-Cover Company is a manufacturer of shelving for books. The company has compiled the following cost data, and wants your help in determining the cost behavior. After reviewing the data, complete requirements (1) and (2) that follow. Units Total Total Total Machine Produced Lumber Cost Utilities Cost Depreciation Cost 13,000 shelves $156,000 $15,950 $145,000 26,000 shelves 312,000 30,900 145,000 52,000 shelves 624,000 60,800...
Challenge 5 Read ALL of the instructions carefully before starting the exercise! Dear Colleague, Earlier today...
Challenge 5 Read ALL of the instructions carefully before starting the exercise! Dear Colleague, Earlier today I built my fourth website using HTML5 and CSS3. This time I wanted to try using CSS float layout options on a website dedicated to my favorite topic: robotics. I wanted my website to look like what is shown in Figure 1 (see below). However, after giving it my best effort, things once again didn’t turn out the way I wanted (see the code...
The assignment summary sheets will be submitted week 14 with Test 3. You are to personally...
The assignment summary sheets will be submitted week 14 with Test 3. You are to personally experience the power and satisfaction of developing these skills firsthand and to reflect and write about this experience. Over the years, many students have shared amazingly rewarding experiences as they worked on these skills. The assignment will be evaluated and be weighted as 5% of your final mark (together, they are worth 20% of your mark for Test 3, which is worth 25% of...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT