Tag Info

Hot answers tagged

8

If you can install software on your work computer, then you could install win-sshfs and a ssh client such as PuTTY on your Windows machine. You can then ssh into the remote Ubuntu server to run LaTex and create your files, after which you could use win-sshfs to access those files from the Windows machine. This way, you'd only need the one ssh port open on ...


8

This problem might actually be easiest to do with ed, since it's a basically a scriptable text editor, rather than a stream processor. Using ed, you don't have to save all the lines of the file into an array, for instance, since it's already doing that for you. # Create test file ~> printf "%s\n" aaaaaa bbbbbb cccccc dddddd eeeeee >test.txt ~> cat ...


7

On the face of it, it's a simple dd: dd if=sparsefile of=sparsefile conv=notrunc bs=1M That reads the entire file, and writes the entire contents back to it. In order to only write the hole itself, you first have to determine where those holes are. You can do that using either filefrag or hdparm: filefrag: # filefrag -e sparsefile Filesystem type is: ...


7

Directory permissions: The write bit allows the affected user to create, rename, or delete files within the directory, and modify the directory's attributes The read bit allows the affected user to list the files within the directory The execute bit allows the affected user to enter the directory, and access files and directories inside The sticky bit ...


7

rm [0-9][0-9].* will do it for files in the current directory (no quotes — you want to match files). The . doesn't need to be escaped, because this is a shell glob and not a regular expression (if it were a regex, that would be a wildcard). If you are looking to do this recursively, find is probably your best bet.


5

You can just pass through sort: $ md5deep -rl * | sort -k2 d41d8cd98f00b204e9800998ecf8427e 2014-12-01/IMG_1969.png bd12c358db0c97230b9d48f67b2c0c98 2014-12-01/IMG_1970.png c3a9d8cb047192a03b857023948a7ba6 2014-12-01/IMG_1971.png If your file name can contain newlines or other strangeness, use this instead (assumes GNU sort): $ md5deep -0rl * | sort -zk2 ...


5

You can run a program from your home computer over SSH. The application will still run on the computer at home but be streamed over the internet. This can be done via X forwarding. An X forwarding tutorial can be found at the following 2 URL's; https://help.ubuntu.com/community/SSH/OpenSSH/PortForwarding ...


5

Recursively : find . -type f -name '[0-9][0-9].*' -delete require GNU find, or : find . -type f -name '[0-9][0-9].*' -exec rm {} \;


4

You can use the vim command :X to encrypt the file. It will prompt you for an encryption key, twice. Then save the file as normal. If someone tries to read the file (including root user), it will be gibberish: Mark@MarkBeast ~ $ vim test.txt Mark@MarkBeast ~ $ cat test.txt VimCrypt~01!o▒rl▒_▒Ĩ7vE=▒g Mark@MarkBeast ~ $ When you vim the file later, it ...


4

You can try something like: EXT=${FILE#*.} NAME=${FILE%%.*} mv "$FILE" "$NAME$(date --reference "$FILE" '+%Y%m%dT%H%M').$EXT" in a script, if your date supports --reference, which picks up the last modification date of the reference file.


4

I think this could work: for i in *; do fileTime=$(stat -c %Y "$i"); #Get last modification (since EPOCH) formatDate=$(date +%Y%m%dT%H%m -d @"$fileTime"); #Get time in format YYYYMMDDTHHmm mv "${i%%.*}"_"$formatDate"."${i#*.}"; #Appends "formatDate" before extension done Regards.


4

You don't need the cat. sed happily accepts the file name as argument: sed 's/^ *//' <file> If you use GNU sed you can use the -i or --in-place switch to edit the file in place: sed -i 's/^ *//' <file> To answer the question, you can achieve “full file buffering” using the tool sponge from the moreutils package. Using sponge you can do: ...


4

There are 3 avenues that I can conceive of that might provide you with a solution. 1. Custom sftp Subsystem You could wrap the sftp-server daemon via sshd_config and "override" it with your own script that could then intercept what sftp-server is doing, and then act when you see that a file was downloaded. Overriding the default sftp-server in sshd_config ...


4

A simple workaround would be to use dropbox, or any type of software that lets you sync between linux and windows (also see Unison and BitTorrent Sync). If you have dropbox running in both computers, then your work folder will be synchronized almost instantly. This way you can have the updated pdf in a few seconds after compiling.


4

Detecting UTF-8 encoding: file will usually give you the encoding; to get a more processable output from file, you've got to pass some options, and cut it until you get the part that describes the encoding: file --brief --mime myfile.txt | cut -d '=' -f 2 Note that it may either be 'us-ascii' or 'utf-8', depending on whether it finds some UTF-8 ...


4

Hold buffer method: sed '$x;1!H;1p;$!d;x;s/\n// ' <<\IN aaaaaa bbbbbb cccccc dddddd eeeeee IN ...that will Hold every line which is !not the first, and the first it prints. On the $last line it exchanges hold and pattern spaces before it does the Hold - which gets the saved lines appended to the last line - then deletes from output all lines which ...


3

Needing only one command is a hard thing to achieve with unix philosophy in mind. On the other hand: you can rule major parts of your world using one-liners. First fix the configuration files in sites-available with the script from the question, then use the following code to create new symlinks in sites-enabled. cd /etc/apache2/sites-enabled find . ...


3

You can't test a file with a regex nor a glob like this. You have to iterate over the files : for file in /Applications/xml[0-9].pl; do if [ -f "$file" ]; then ...


3

The simplest way I could find is: touch $(paste -d '.' <(printf "%s\n" File{001..005}) \ <(printf "%s\n" {000..004})) This will create File001.000 File002.001 File003.002 File004.003 File005.004 To understand how this works, have a look at what each command prints: $ printf "%s\n" File{001..005} File001 File002 File003 ...


3

Yes it is possible, but there are multiple steps involved: You must be able to reach your home computer running Linux from the internet. This means opening up port 22 (ssh) or your router at home, or a higher port if your provider blocks incoming access on ports below 1024. Then install openssh-server (and make it listen on any non-default port). You also ...


3

For a user someusername to be able to write in folder, that was initially made by root, you need to change the rwx permissions and/or the owner resp. group. If you restrict the permissions then someusername needs to be either owner or group member. If you do chmod 777 /somefolder, everyone can read and write, including someusername. If you do chmod 770 ...


2

To squash multiple hyphens (one hyphen followed by one or more hyphens) into a single one for all files in the current directory use: rename 's/--+/-/g' -- * The -- is important if files start with a hyphen, otherwise they would be interpreted as command line arguments. The * expands to the list of files in the current directory.


2

I found an easy way to creating files and also directory with random names and extensions: To create random file with random ext use this command: $ mktemp XXX.$(mktemp -u XXX) -u, --dry-run do not create anything; merely print a name (unsafe) And for creating multiple files use above command inside a loop: $ for create in $(seq 5); do ...


2

If they have the root password, as you say in a comment, there is no way to prevent them doing anything with the file because they can always just su(do) to edit or delete it. If you don't want to remove their root access by changing the password and either changing their accounts group memberships or editing the sudoers file, about the only thing you can ...


2

If you want to guarantee that they are different, look into mktemp: $ mktemp /tmp/tmp.r8FumWPhn5 $ mktemp XXXXXXXX.tmp Pu4Ii6Sf.tmp


2

sed -d 's/\s/\n/g' * | sort | uniq -c | sort -nr >> lyrics01wordcount.tf Simple.


2

Configure the SSH server to log the activity, then you can parse the log to know if such file has been downloaded. To enable logging append -l INFO to the sftp subsystem line in the /etc/ssh/sshd_config file, it should look something like (the path may vary by distro, I'm using SuSE 11): Subsystem sftp /usr/lib64/ssh/sftp-server -l INFO Now the ...


2

Since you already do mention PuTTY, you already have all you need to find out how to solve the problem. You have several options. One is using an SSH client (e.g. PuTTY) to connect to the server, running: $ cat > path/to/resulting/file <<EOD ... your pasted text goes here ... EOD or just using a SCP client to just copy the file there. With pscp ...


2

OK, I have remade this script, and by sorting it backwards it looks like it should work. It compares the year and month to the previous one, and if it is lower it should be the last entry for that month. #!/bin/bash #the tac reverses the listing, so we go from newest to oldest, vital for our logic below FILES=`ls | tac` #create a cutoff date by taking ...


2

The first directory find /var/tmp finds is /var/tmp. If you want to skip that one (and use Gnu find) then you can change the command to: find /var/tmp -depth -mindepth 1 -type d -ctime -1 -exec rm -rf {} \; or find /var/tmp -mindepth 1 -type d -ctime -1 -exec rm -rf {} \; -prune Without -depth and -prune error messages may occur because rm -rf ...



Only top voted, non community-wiki answers of a minimum length are eligible