Reputation
154,842
Next tag badge:
768/1000 score
208/200 answers
Badges
23 237 421
Newest
 Necromancer
Impact
~8.4m people reached

1d
comment In UNIX, how do I send a file back to it's original location after outputting it somewhere else?
~/file1 > /newlocation/filestorage doesn't move the file do a new location, it executes ~/file1 and stores its output in the new location.
1d
comment Serialize shell variable in bash or zsh
Escaping newline doesn't allow it to be preserved, it makes it go away once read. backslash-newline for read is a way to continue a logical line onto another physical line. Edit: ah I see you mention the problem with newline already.
1d
comment Serialize shell variable in bash or zsh
That solution depends on $IFS being unmodified and now fails to restore empty array elements properly. In fact, it would make more sense to use a different value of IFS, and use -d '' to avoid having to escape newline. For instance, use : as the field separator and only escape that and the backslash and use IFS=: read -ad '' array to import.
1d
comment Serialize shell variable in bash or zsh
It doesn't work if the elements contain non-printable (in the current locale) or control characters like TAB or newline as then bash and zsh render them as $'\xxx'. Try with bash -c $'printf "%q\n" "\t"' or bash -c $'printf "%q\n" "\u0378"'
Apr
27
comment Reading user input with read back
Note that the code would work in csh but do something different. Since csh has no read builtin, It would invoke a read command on the filesystem (which could not possibly set csh's $NAME variable), The echo "Hi $NAME!" would work if $NAME was set as an environment variable on in ~/.cshrc or anywhere else in the csh script prior to the source.
Apr
27
comment “No space left on device” when trying to copy small folder to an external drive with alot of free space
How are you copying?
Apr
27
comment What is the setting in bash for globbing, to control whether * matches dot files
With zsh, the better option is to enable dotglob on a per-glob basis: mv test/*(D) /dest
Apr
27
comment Scalability of 'sort -u' for gigantic files
@Random832 and it's meant to be able to overwrite the file over itself (sort -o file file)
Apr
26
comment linux : find a lastname that has 5 characters only in a text
Note that \s and \S are GNU specific. The standard equivalent (for grep -E the standard equivalent of egrep) are [[:space:]] and [^[:space:]] ([:space:] being [:blank:] plus some additional vertical space character like form feed, carriage return, vertical tab, line/paragraph separator..). Like their standard equivalent, they match collating elements which may be made of more than one character.
Apr
26
comment Scalability of 'sort -u' for gigantic files
25 years ago, UTF-8 was not invented yet? Support for UTF-8 locales was added in Solaris 7 (1, 2). Are you referring to some other multibyte character set?
Apr
26
comment Scalability of 'sort -u' for gigantic files
So are you actually talking of the Oracle vendor specific version of sort? Or any derivative of some version of AT&T Unix sort? Or any Unix certified version of sort (like GNU sort on OS/X)?
Apr
26
comment Scalability of 'sort -u' for gigantic files
GNU sort sorts in parallel by default (since 2010 after that page you're linking to), --parallel there is to reduce the number of concurrent threads instead of letting sort determine the optimum one. Sort already does a splitting and merging internally in a more efficient way. I doubt doing that extra splitting will help.
Apr
26
comment Scalability of 'sort -u' for gigantic files
What exactly do you call the UNIX sort implementation? Is it the original one from Unix version 3? The man page there says it can't sort files bigger than 128KiB.
Apr
26
comment Scalability of 'sort -u' for gigantic files
Note that GNU sort can compress those temp files to pack even more (and increase performance with slow disks).
Apr
25
comment How do I search find files and compress if greater than 500M
@sabarishjackson, in the first version, I had forgotten the !. ! -name '*.gz' matches on file names that don't end in .gz.
Apr
24
comment How can I work with binary in bash, to copy bytes verbatim without any conversion?
Note that dd is not necessarily equivalent to head for non-regular files. head will do as many read(2) system calls as necessary to get those 988 bytes while dd will just do one read(2). GNU dd has a iflag=fullblock to try and read that block in full, but that's then even less portable than head -c.
Apr
23
comment Is a string an arithmetic expression?
Note the difference when foo=1+1
Apr
22
comment Portability of “> /dev/stdout”
What was your test case? bash is special as it can be compiled to handle /dev/fd/x by itself for redirections on systems that don't have /dev/fd
Apr
22
comment Portability of “> /dev/stdout”
Related: Portability of file descriptor links
Apr
21
comment Block Particular Command in Linux for Specific user
/etc/profile.d/ is not for bash completion, it's where to place login session customisations for users using POSIX-like login shells, so it's typically not where bash alias customisations (which would rather go in /etc/bash.bashrc) would go and it should have a POSIX shell syntax (so typically, . instead of source and = instead of ==).