Commands tagged file transfer (7)


  • 6
    ssh HOST cat < LOCALFILE ">" REMOTEFILE
    Mandark · 2009-12-22 16:35:34 7
  • This will move a folder and merge it with another folder which may contain duplicates. Technically it's just creating hardlinks of everything in the folder, and after it's done, delete the source (with rm -r source/ ) to complete the move. This is much faster than, for example, using rsync to merge folders which would actually copy the entire contents and so for a lot of files would take much longer. This uses macutils gcp port of cp so it can be used on osx/MacOS. If using in linux or some unix where cp includes the ability to create links with -l you can just use cp instead of gcp.


    2
    gcp -r -l source/ destination/
    fivestones · 2017-02-09 23:48:38 20
  • Nice command for when you don't have scp available for whatever reason. Works with binaries.


    0
    cat LOCALFILE | ssh HOST "cat > REMOTEFILE"
    eataudio · 2011-02-03 05:29:06 4
  • cat didn't seem to work with binaries to well for me, the above command seemed to do the trick. Opps should be pointed out its going through a "hop" box (which is why I was searching here in first place), only need the last bit (after the -t) if doing it directly from one box to another...


    0
    ssh username1@servername1 -t ssh username2@servername2 uuencode -m testfile1.tar - | uudecode > testfile1.tar
    djt78 · 2013-01-28 17:06:00 4
  • Functionally the same as the Microsoft Robocopy (https://en.wikipedia.org/wiki/Robocopy) command below but with the benefits of compression and optionally specifying a user. robocopy /e [//host]/source/path [//host]/destination/path Options: -a: archive mode - rescursive, copy symlinks as symlinks, preserve permissions, preserve modification times, preserve group, preserve owner, preserve device files and special files -hh: Numbers in human-readable K=1024 format. Single "h" will produce human-readable K=1000 format -m: don't copy empty directories -z: use compression (if both source and destination are local it's faster to omit this) --progress: Shows progress during the transfer and implies --verbose (verbose output) --stats: Summary after the transfer stops Show Sample Output


    0
    rsync -ahhmz --progress --stats [[user@]host:]/source/path/ [[user@]host:]/destination/path/
    juangmorales · 2014-11-13 18:52:45 20

  • 0
    cat file | ssh user@remotehost "cat > file"
    luckyone777 · 2017-07-26 20:36:02 18
  • I have come across multiple situations where I could only get to a server from a very restrictive bounce point which would not allow file transfers. I was able to uuencode a file, copy the output to a text file over putty, and then uudecode the file to transfer it. This works with any kind of file. Show Sample Output


    -4
    uuencode -m <filename> <filename>
    leprasmurf · 2009-12-22 15:28:59 3

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands


Check These Out

tail -f a log file over ssh into growl

Display disk partition sizes
It is the same but more faster real 0m0,007s user 0m0,011s sys 0m0,000s with my solution real 0m0,038s user 0m0,044s sys 0m0,000s with your solution :)

dump database from postgresql to a file

Keep a copy of the raw Youtube FLV,MP4,etc stored in /tmp/
Certain Flash video players (e.g. Youtube) write their video streams to disk in /tmp/ , but the files are unlinked. i.e. the player creates the file and then immediately deletes the filename (unlinking files in this way makes it hard to find them, and/or ensures their cleanup if the browser or plugin should crash etc.) But as long as the flash plugin's process runs, a file descriptor remains in its /proc/ hierarchy, from which we (and the player) still have access to the file. The method above worked nicely for me when I had 50 tabs open with Youtube videos and didn't want to have to re-download them all with some tool.

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

Change the homepage of Firefox
Pros: Works in all Windows computers, most updated and compatible command. Cons: 3 liner Replace fcisolutions.com with your site name.

Copy without overwriting

Fast, built-in pipe-based data sink
This is shorter and actually much faster than >/dev/null (see sample output for timings) Plus, it looks like a disappointed face emoticon.

bash screensaver off

return the latest kernel version from a Satellite / Spacewalk server software channel


Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: