New answers tagged

3

You also need to strip off the front of $dir with dir=GPS${dir#*GPS}. The resulting script: $ ls 121123_SN323_A_L002_GPS-100_R1.fastq.gz 121123_SN323_A_L002_GPS-100_R2.fastq.gz 121123_SN323_A_L002_GPS-104_R1.fastq.gz 121123_SN323_A_L002_GPS-104_R2.fastq.gz 130201_SN132_B_L007_GPS-100_R1.fastq.gz 130201_SN132_B_L007_GPS-100_R2.fastq.gz ...


1

Seems like it is not trivial to get directory listing over http; I could get the bz2 files using bellow: wget -k -l 0 "http://archive.xfce.org/xfce/4.6.2/src/" -O index.html ; cat index.html | grep -o 'http://archive.xfce.org/xfce/4.6.2/src/[^"]*.bz2' | uniq -c | xargs wget Hope this help.


0

du naturally traverses the directory hierarchy and awk can perform the filtering so something like this may be sufficient: du -ak | awk 'BEGIN {sum=0} /\.jpg$/ {sum+=$1} END {print sum}' This works without GNU.


2

The trailing '/' on the source directory name is a subtlety of rsync. Pay attention to it. rsync A trailing slash on the source effectively means "copy the contents of this directory, not the directory itself". Without the trailing slash, it means "copy the directory". So rsync -a tmp/24/ host:/target will copy the contents of "/tmp/24/" into "host:/...


1

huh, so my problem can be solved like this: ssh host "mkdir -p /target" scp tmp/24/* host:/target


0

Do you have an entry for user1 in your /etc/passwd ? If you want to change the ownership of the directory you can type as root: chown apache:apache /var/www -R You can also add user1 to apache group and in this way your web server will fine. Maybe it's good idea to read the following topic: How can I create an SFTP user in CentOS?


1

You can override the builtin compgen for simple directory completions (as for cd and ls). For example, put this function in your ~/.bashrc compgen(){ local IFS=$'\n' local x tmp x=$( builtin compgen "$@" ) && while read -r tmp; do [[ "$tmp" =~ ^/home/e && ! "$tmp" =~ ^/home/elsherbini$ ]] || echo "$tmp" ...


1

I'm using zsh which allows completion to be customized very thoroughly. This option prevents certain patterns from completion: autoload -Uz compinit; compinit # ignore some common patterns that we usually don't want as completions zstyle ':completion:*' ignored-patterns "/usr/share/iscan" "/usr/lib/iscan" \ "iscan" "/usr/lib/ispell" "ispell" "/usr/...


1

One way I'd suggest is to have an alias if we are just concerned about the home directory path, adding the below to your profile would help here, whatever unique alias you made should autocomplete with even a first character. alias myHome="cd /home/elsherbini" . .profile my\T pwd /home/elsherbini EDIT: The other way could be binding a key but even this ...


2

ls displays that information because the data is stored in the size field of the inode for the directory. This is filesystem dependent. A given filesystem could hold other information there. As an example, ZFS reports the number of directory entries in that field. If that's the level you're interested in, then reading the data is simple. ls and stat are ...


1

Yes, there is: it's called ls… The size reported by ls for a directory is the size of the directory contents. It isn't metadata of the directory, it's metadata of the files in the directory. Most of that is listed with ls -la. On some Unix variants, you can display the binary form of that data by calling cat (or od, etc.) on the directory. This is not the ...


0

Improving SHW's great answer to make it work with any locale, like Zbyszek already pointed out in his comment: LC_ALL=C find ./photos/john_doe -type f -name '*.jpg' -exec du -ch {} + | grep total$


0

i found the answer.. Because i was installing the app at my sd card thats why i could not access or change the permissions of the folder.. because it was located at the sd card and not at the phone storage.. fix that by installing the app at the phone storage!


0

I'd use perl here: perl -lne ' for (/\w+/g) {$count{lc $_}->{$ARGV}=undef} END {print "$_: " . keys %{$count{$_}} for keys %count}' ./*


3

You can use something similar to this: #!/bin/bash counter(){ for file in "$1"/* do if [ -d "$file" ] then echo "$file" counter "$file" fi done } counter "$1" Run it as ./script.sh . to recursively print directories in under the current directory or give the path to some other directory to traverse.


2

In a zip file, only file contents is encrypted. File metadata, including file names, is not encrypted. That's a limitation of the file format: each entry is compressed separately, and if encrypted, encrypted separately. You can use 7-zip instead. It supports metadata encryption (-mhe=on with the Linux command line implementation). 7z a -p -mhe=on Directory....


1

You could create an archive using your favorite tool and then use bcrypt to perform encryption/decryption. A) To create an encrypted file: tar -czf Directory.tgz /path/to/directory bcrypt Directory.tgz This will give you a Blowfish-encrypted file Directory.tgz B) To reverse this process: bcrypt Directory.tgz.bfe tar -xf Directory.tgz


83

Removing the current directory does not affect the file system integrity or its logical organization. Preventing . removal is done to follow the POSIX standard which states in the rmdir(2) manual page: If the path argument refers to a path whose final component is either dot or dot-dot, rmdir() shall fail. One rationale can be found in the rm manual ...


7

It's done like that for integrity since you are currently inside that directory and the . is only a self-reference. You need to either go in its parent or call rmdir with its path, which can be done with: rmdir `pwd` If you often need that, you can set an alias to it like: alias rmc='rmdir `pwd`' .. which could be called as rmc alone to remove ...


0

With a perl one-liner (reformatted for readability): perl -e 'opendir($dh, "."); while ( readdir($dh) ) {$count++}; closedir $dh; print "$count\n";' or perl -e 'opendir($dh, "."); @files = readdir($dh); closedir $dh; print $#files+1,"\n";' You can use perl functions that modify arrays like grep or ...


1

You can use GParted to rename partition. To install GParted use, $ sudo apt-get install gparted Launch GParted -> Unmount the drive -> Rename by setting new label. For more info visit this website.


2

The easiest thing to do is to for a permanent result is to give the filesystem a label. The way you do this depends on what filesystem you formatted it as. First find the device it is on: $ findmnt /mnt/d1b2aa11-a3e4-434b-b71c-47a8ac23ac23 TARGET SOURCE FSTYPE OPTIONS ... /dev/sdc1 vfat ... For example, above it is on /dev/sdc1 (check this isn't ...


0

It definitely looks like it could have been a permissions or a network issue. But on my last note, I mentioned that: My Netowrk adapter, in the Settings on VBox, was set to NAT. As soon as I changed it to Bridged, then restarted the VM, it worked and didn't show the ?'s So this seemed to have fixed it. I haven't seen this since, so it had to have been ...


1

This worked using bash on Ubuntu. It only matches duplicate directories irrespective of depth in the tree. The portion within the $() builds a list of pipe-separated directory names by counting duplicates in the last column of ls -l. This pipe-separated list is filtered using grep over the list of all directories. Also, not accounting for other files (didn't ...


3

If you don't have write permission in the parent directory, you can't make any changes in the parent directory; this includes deleting the target directory, and creating a symlink. In any case, ln won't overwrite a directory, even with -f.


2

TBH this is probably more suited to one of the other .SE's, either Unix &Linux, Ask Different, or even SuperUser. Which is why I assume you've been downvoted. That said... The Short Answer The answer is rm -r ./--crm, or better yet, rmdir ./--crm. The Real Answer On OS X you're usually using Bash in the terminal, which is important to know: which ...


0

chmod 0700 /path/to/directory This command will make directory readable, writable, and executable only to the user who owns it. You probably don't want other users to have read access to a directory that holds a private certificate.


3

You can achieve that with ACLs, check this answer for an introduction: http://unix.stackexchange.com/a/12847/130303 You'll probably need default ACLs to achieve what you want to do. Lets say you have a directory test (with files and dirs already in it) and you want user and group to be able to write and others only to read, you can set default ACLs (...


0

To find dirs containing files modified in the last 24 hours: find [dir-to-search] -type f -mtime -1 -exec dirname {} \; | sort --unique Change the mtime -1 to mtime -2 to search the last 48 hours, or change it to mmin -120 to search the last 2 hours Edit: explanation: Searches dir-to-search (or current dir if not provided) recursively for entries of ...



Top 50 recent answers are included