Tag Info

New answers tagged

1

I expect that the files have more space allocated on disk than they are actually using. Normally I'd expect to see this only in binary files where blocks of NULLs are not stored. Since fastq format is text however I think the file allocation extends past the end of the data. Try the command ls -lsh and compare the two sizes listed for each file. Column 1 is ...


1

I do not think it would make much sense to implement such functionality in 'cd'.. It would work if every subdir had only one sub-subdir, but what if there's a tree [i.e. several subdirs in a dir]? Which path should it take? 'cd' is not a mind reader. Consider the following two direcroty trees: <some_parent_dir> | |-<subdir> | | | ...


2

if lastdir is the only directory of that name in your directory hierarchy, you might get away with this in bash (although it may take a while to run) shopt -s globstar cd **/lastdir


0

You might do: TMPDIR=${TMPDIR:-${TMP:-$(CDPATH=/var:/; cd -P -- tmp)}} cd -- "${TMPDIR:?NO TEMP DIRECTORY FOUND!}" The shell should either find one of the 4 alternatives or exit with error. Still, POSIX defines the $TMPDIR variable (for XCU systems): TMPDIR This variable shall represent a pathname of a directory made available for programs that need ...


4

If you're looking for the same thing in fewer lines... for TMPDIR in "$TMPDIR" "$TMP" /var/tmp /tmp do test -d "$TMPDIR" && break done You could write this in one.


11

A slightly more portable way to handle temporary files is to use mktemp. It'll create temporary files and return their paths for you. For instance: $ mktemp /tmp/tmp.zVNygt4o7P $ ls /tmp/tmp.zVNygt4o7P /tmp/tmp.zVNygt4o7P You could use it in a script quite easily: tmpfile=$(mktemp) echo "Some temp. data..." > $tmpfile rm $tmpfile Reading the man ...


0

You can do this in pure Tcl without exec: #!/usr/bin/env expect set path dir1/dir2/dir3 file mkdir $path ;# [file mkdir] in Tcl is like mkdir -p file attributes $path -owner system


1

If rsync is not an option, I would next recommend lftp: lftp sftp://user@host.com/path/path/ Then use the mirror command to recursively upload, like this: mirror -R Or to upload just: mirror You have to cd into the directories you want to mirror. Works great!


1

Directories have two ways of operation. The first is to read or browse a directory, also known as running the ls command, and the other is executing a directory. Executing is required to open a file or directory in the requested directory. Executing is doing an inode lookup for the requested name and you don't have to be able to read the directory for that. ...


2

Read permissions on a directory only allow you to list its contents. To actually be able to access the contents, you need execute permissions. Conversely, having only execute permissions will allow you to access the contents, but not list them. See Why do directories need the executable (X) permission to be opened?


1

Instead of cp -r usr/* /usr, do: cp -ri usr/* /usr The -i flag will make the copy process interactive and will ask your permission if it will overwrite any files. You will have an option either to grant or not to grant the permission. P.S:- The version of cp on my test server is 8.4. It does not ask for permission before over-writing files unless I use cp ...


0

No it won't. It will only write over files that exists in both locations or copy new ones leaving old files in the destination alone.


0

This should get all the words from all the files, sort them and get unique words, than iterate through those words and count how many files it occurs in. # find all words from all files within the directory grep -o -h -E '\w+' directory/*|sort -u | \ while read word; do # iterate through each word and find how many files it occurs c=`grep -l ...


0

XZ_OPT=-9e tar cJf tarfile.tar.xz directory is even better than XZ_OPT=-9 tar cJf tarfile.tar.xz directory


1

mv /images/images/ .. moves the directory called images from the directory /images into the parent directory of the current directory. The current directory is whichever directory you were in at the time you ran the mv command. Your directory will not have "disappeared". You just need to work out where you were when you ran the mv command, and from there ...


1

.. denotes the parent directory. Suppose you are in the home/user/TEST folder, where there is the images1/images2 directory. Then you have now a images2 folder in home/user/ and an images1 folder in TEST, without the subdirectory images2: ~$ mkdir TEST ~$ cd TEST ~/TEST$ mkdir -p images1/images2 ~/TEST$ touch images1/images2/a_file ~/TEST$ mv ...


1

You can use the -l option of the cp command, which creates hard links of files on the same filesystem instead of full-data copies. The following command copies the folder source/folder to a parent folder (destination) which already contains a directory with the name folder. cp -rl source/folder destination rm -r source/folder You may also want to use the ...


1

If you are using bash, you can create a function instead of an alias. bcopy () { cd ~/e_empid/ cp file1 /home/e_empid/dir1/dir2/dir3/Backupfile1 cd ~/e_empoid/dir1/dir2/dir3/ } Then you just need to call using bcopy. You could also use $1 and $2 instead of file1 and Backupfile1 if your files does not have the same names every time. cp $1 ...


2

Change your aliases to variable like below without cd command and without space after = sign and remove last / because the aliases won't work inside cp command or you can use function instead; As @jherran's answer which it's more flexible with function. sorc=~/e_empid dest=~/e_empoid/dir1/dir2/dir3/Backupfile1 Then use that like: cp $sorc/file1 $dest/ ...


0

I came across the same issue and ended up writing this to make it work painlessly across different systems (debian, ubuntu currently): Run make_chroot_initrd script to create a new chroot-enabled initrd image from the existing one: # ./make_chroot_initrd /chroot/trusty/boot/initrd.img-3.13.0-32-generic making new initrd: ...


3

By default, find includes everything in its search: directories, files, and symlinks. find "/path/to/dir" -mmin -30 -not -name ".*" -exec zip -r "testfile.zip" "{}" \+ If /path/to/dir was modified in the last 30 minutes, it will pass all the tests, and zip, since it was given the -r option, will add the directory and everything under it to the archive. ...


0

With rcp, and scp use the -r option to recursively copy a directory and all it's contents (including other directories). With cp use -R. scp -r programming myName@orca.st.usm.edu: Just worked fine for me.


0

Here is a script that worked for me. I prefer mv over rsync, so I use Jewel and Jonathan Mayer's solutions. #!/bin/bash # usage source1 .. sourceN dest length=$(($#-1)) sources=${@:1:$length} DEST=$(readlink -f ${!#}) for SRC in $sources; do pushd $SRC; find . -type d -exec mkdir -p ${DEST}/{} \; find . -type f -exec mv {} ${DEST}/{} \; ...


0

If you want to save foldename as csv file use this command: ~/test$ ls -d */|tr -d '/'| paste -sd , > outfile.csv dir1,dir2,dir3 ls -d */: list all directory names in current directory(in my case current directory is /home/KasiyA/test/). tr -d '/': removes / at the end of each name of directories. paste -sd ,: paste the result of previous tr command ...


-1

Try this: ls -ld */ | awk -v OFS="," 'NR>1{print $3,$4,$5,$6" "$7,$8,$9}' > output.csv Include only the column numbers you want in the {print .....} block. EDIT: Play around with the coloumn numbers to arrange the coloumns in the order you wish to.


0

If you want folder names, do: find . -maxdepth 1 -mindepth 1 -type d -printf '%P,' | sed 's/,$/\n/' > output.csv Parsing the output of ls is bad idea. find can be used in combination with other tools to emulate the output of ls in many cases, and is a better tool for the job. -maxdepth 1, -mindepth 1: find will usually recursively search inside any ...


0

On Linux and ext4 file system, a hacky way to prevent directories (and not other types of files) from being created is to rely on the fact that newly created directories inherit the default ACL entries from their parent directory (in addition to the corresponding non-default ACL entries) while files only get assigned the corresponding non-default ACL entries ...


1

I am not aware of a possibility to lock the file system meta data in the cache but (if there are not too many files) you can read the meta data regularly in order to keep it in the cache: find /path/to/dir -printf ""


1

None of the following are the real reason for disallowing hard links to directories; each problem is fairly easy to solve: cycles in the tree structure cause difficult traversal multiple parents, so which is the "real" one ? filesystem garbage collection The real reason (as hinted by @Thorbjørn Ravn Andersen) comes when you delete a directory which has ...


0

First, gain access to the terminal and execute ls -al file with file being the file you want to convert back into an ACTUAL folder. If there are files and sub-directories listed it means your "file" was previously a folder with real content and you may continue: Execute: sudo chmod 700 / OR sudo chmod 700 file Restart the system and regain terminal ...



Top 50 recent answers are included