Sponsored Content
Full Discussion: Copy script
Top Forums UNIX for Dummies Questions & Answers Copy script Post 302835795 by Don Cragun on Tuesday 23rd of July 2013 03:10:21 AM
Old 07-23-2013
Quote:
Originally Posted by telekomancer
Hi maybe you can try this:

Code:
tail -3 REPORT.txt > Report.txt && cp Report.txt  <directory>

in linux doesn't exist disks as letters (ex. H: ) so you have to mount it and copy it
The first thing the command above will do is delete all of the contents of the file Report.txt. Then, if the -3 option is accepted by tail, it will copy that empty file to whatever directory is named as the final operand to cp.

-3 is an obsolescent option form for tail that is no longer specified by the standards. The other error message is obvious: The destination directory you have given to cp does not exist. You'll have to get a correct pathname for your target directory; I can't guess at what that might be. For the other problem you could try:
Code:
cp  $(ls -tr *REPORT*.txt |tail -n 3) target_directory

This User Gave Thanks to Don Cragun For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Copy Script Problems .....

I got this script: print -n "Enter file name: " read name .... ..... ..... etc but at the prmpt, when I press enter (without typin a word), comes up with sum error message, is there away of getting it not to print that message?? (8 Replies)
Discussion started by: Makaveli.2003
8 Replies

2. Shell Programming and Scripting

copy script

I am trying to figure out how to copy a file that changes daily to a new directory with a different name each day. Example : webfile created today copy webfile to /hold/webfile.1 tommorrow copy webfile /hold/webfile.2 Is there a way to do this? I can't seem to figure this out. This needs to... (2 Replies)
Discussion started by: scbrown2
2 Replies

3. Shell Programming and Scripting

Help:Copy file from one to other using script

Hi Frineds, Through my DTS process I am generating one file at one directory like, /sqlsrvr_demo/dts/put/transaction_fact.csv now I want to copy this files(only when the files size is greater than 0 kb) to some other directory like /sqlsrvr_demo/dts/get/transaction_fact.csv Can... (2 Replies)
Discussion started by: sunnysunny
2 Replies

4. Shell Programming and Scripting

Help with Find All/Copy Script

Hi Gang, I am an old unix user and just recently returned in the flavor of a Mac. I have tons of pictures in the .orf format and would like to write a script to: Search the Hard drives for that file type Then, depending on date, copy it to a specific folder If there is an exact... (2 Replies)
Discussion started by: jlfx
2 Replies

5. Shell Programming and Scripting

Remote Copy Script

Hi All, My first post on the Forums! I've just whipped up a quick script to slightly automate a log file retrieval process for work and to be completely honest my BASH scirpting knownledge is extremely limited as is my understanding of a lot of linux commands. Basically the scripts purpose... (3 Replies)
Discussion started by: effektd
3 Replies

6. Shell Programming and Scripting

copy script

I have a little copy script, #! /usr/bin/bash FILE_COPY_LIST=$1 SOURCE_DIRECTORY=$2 DESTINATION_DIRECTORY=$3 while read file do if ; then echo $file " cannot be found" fi cp -f $SOURCE_DIRECTORY'/'$file $DESTINATION_DIRECTORY done < $FILE_COPY_LIST This just... (3 Replies)
Discussion started by: LMHmedchem
3 Replies

7. UNIX for Dummies Questions & Answers

Help with Copy Shell Script

Hello, I am currently learning UNIX scripting and have written a simple copy program. However, upon execution, it returns an error despite debugging correctly. Can anyone assist in explaining this? Attached screenshots illustrating a test execution. Many thanks. (13 Replies)
Discussion started by: dixer
13 Replies

8. Shell Programming and Scripting

Help with file copy script

Hello, I am still pretty new at writing shell scripts and may have bitten off more than I can chew. I am trying to write a script that figures out if a file exists (a known name) in directory a, then copy it to my selected destination, otherwise, look in directory b and check there. If it is in... (14 Replies)
Discussion started by: r34lj4k3
14 Replies

9. Shell Programming and Scripting

Script for File Copy

Hello All, This is my first post to unix.com. I have requirement to copy multiple *.dmp files from one server to other server. I have that other server NFS filesystem mapped to source server. Dump files are so huge almost 20TB. There are around 15-20 files each of 1.1TB. I want to copy these... (6 Replies)
Discussion started by: Amit Bansode
6 Replies

10. Shell Programming and Scripting

How to copy script output to a variable using same script?

I'm trying to copy script output and use it in this same script as a variable, and call the variable when script is compiled. The script is below. #!/bin/bash output=$(script) while read line; do if ]; then grep "$line" logfile.txt # Create text file echo "From: IT ... (4 Replies)
Discussion started by: SysAdminRialto
4 Replies
TAIL(1) 						      General Commands Manual							   TAIL(1)

NAME
tail - deliver the last part of a file SYNOPSIS
tail [ +-number[lbc][rf] ] [ file ] tail [ -fr ] [ -n nlines ] [ -c ncharacters ] [ file ] DESCRIPTION
Tail copies the named file to the standard output beginning at a designated place. If no file is named, the standard input is copied. Copying begins at position +number measured from the beginning, or -number from the end of the input. Number is counted in lines, 1K blocks or characters, according to the appended flag or Default is -10l (ten ell). The further flag causes tail to print lines from the end of the file in reverse order; (follow) causes tail, after printing to the end, to keep watch and print further data as it appears. The second syntax is that promulgated by POSIX, where the numbers rather than the options are signed. EXAMPLES
tail file Print the last 10 lines of a file. tail +0f file Print a file, and continue to watch data accumulate as it grows. sed 10q file Print the first 10 lines of a file. SOURCE
/sys/src/cmd/tail.c BUGS
Tails relative to the end of the file are treasured up in a buffer, and thus are limited in length. According to custom, option +number counts lines from 1, and counts blocks and characters from 0. TAIL(1)
All times are GMT -4. The time now is 07:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy