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...
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...
**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...
I did already posted this question before, I did get the answer but i am not...
I did already posted this question before, I did get the answer but i am not satisfied with the answer i did the code as a solution not the description as my solution, so i am reposting this question again. Please send me the code as my solution not the description In this project, build a simple Unix shell. The shell is the heart of the command-line interface, and thus is central to the Unix/C programming environment. Mastering use of...
Team 5 answer the questions What are 4 key things you learned about the topic from...
Team 5 answer the questions What are 4 key things you learned about the topic from reading their paper? How does the topic relate to you and your current or past job? Critique the paper in terms of the organization and quality. Incentive Systems             In this paper, we will focus primarily on financial rewards that companies use to attract, retain and motivate the brightest and most talented candidates in the labor market. By providing a reward system that...
Kimmel Gnomes DATE:​March 1, 2018 TO:​CCSU Consulting FROM:​Candice Kimmel, President, Kimmel Gnomes SUBJECT:​Master Budget for the...
Kimmel Gnomes DATE:​March 1, 2018 TO:​CCSU Consulting FROM:​Candice Kimmel, President, Kimmel Gnomes SUBJECT:​Master Budget for the fiscal year July 1, 2018 – June 30, 2019 ---------------------------------------------------------------------------------------------------------------------------------- Our controller, Richard Kimmel is negotiating with potential new Clay suppliers in Kentucky. We need the Large Gnome Division’s Master Budget for the fiscal year ended June 30, 2019 for our corporate strategic planning process, and we cannot wait for Richard’s return from Kentucky. We would like you to prepare the Large Gnome Division’s...
In narrative essay format, I want you to address a business/organization case study using multiple concepts...
In narrative essay format, I want you to address a business/organization case study using multiple concepts from class. The case question and case text begin on page 5 of this document. You need to demonstrate their best understanding of management and organizational behavior theory, and the application of those ideas to improve the understanding of various issues. You need to clearly identify at least 3 distinct, substantive issues. For each issue you need to 1), identify evidence from the case...