Tag Info

Hot answers tagged

25

You can use the echo or find commands instead of ls: echo * or: find -printf "%M\t%u\t%g\t%p\n"


23

You can also use the printf command, instead of echo: printf '%s\n' * printf is superior to echo in this situation in that echo does not respect the "double dash" (--) to signify the end of the argument list (on some systems, including Ubuntu 14.04 which is what I tested it on): llama@llama:~$ mkdir -p Misc/unix210948 llama@llama:~$ cd !$ cd ...


17

The attempt to use isoinfo comes from lesspipe, which is generally used as a helper for less via the LESSOPEN variable. Running LESSOPEN= less file.raw will open file.raw without interpretation.


14

Another option which doesn't involve setting any variables is to pipe the data through less instead of letting less open the file for you. $ cat file.raw | less or $ less <file.raw would do the trick.


14

It is a bad idea (to have strange characters in file names) but you could do mv somefile.txt "foo bar" (you could also have done mv somefile.txt "$(printf "foo\nbar")" or mv somefile.txt foo$'\n'bar, etc... details are specific to your shell. I'm using zsh) Read more about globbing, e.g. glob(7). Details could be shell-specific. But understand that ...


11

If you use bash, this command should work. mv a $'b\nc'


7

You should probably use the file and uname utilities to get a better idea of just what the hell is going on with your machine. Your error is indicative of a binary executable compiled for a system architecture incompatible with that on which it is invoked. On my machine: uname -m; file /bin/ls ...prints... x86_64 /bin/ls: ELF 64-bit LSB executable, ...


6

The ls version in Mac OS X is based on BSD ls, and doesn't support long-format options including --help. See the ls manpage or man ls on your system for details.


6

Specify the date format, but leave it empty eg. ls -lh --time-style="+" Produces -rwxrwxr-x 1 christian christian 8.5K a.out drwxrwxr-x 2 christian christian 4.0K sock -rw-rw-r-- 1 christian christian 183 t2.c


5

I think REPL (read-eval-print-loop) is what you are looking for. From the wikipedia page: A read–eval–print loop (REPL), also known as an interactive toplevel or language shell, is a simple, interactive computer programming environment that takes single user inputs (i.e. single expressions), evaluates them, and returns the result to the user; a program ...


5

You want to move the systems directory into the courses directory. Just: mv systems courses/


5

You can set this with the PS1 environment variable. pi is the username. raspberrypi is the name of the server. ~ is the current directory (and means 'home dir') $ is the prompt - $ denotes a non privileged user. (# denotes root). PS1 is probably set to: PS1='\u@\h \w \$'


5

Using bash (or many other shells), you can use tab completion to list files: $ thisisnotacommand ./public_html/<TAB> acc/ papers/ android/ l/ sdr/ blast formalcss.html switch/ busy/ formalcss.tar.gz others/ together.jpg


5

Another perl: perl -pe 'BEGIN { binmode \*STDOUT } chomp; tr/AB/\0\1/; $_ = pack "B*", $_' Proof: $ echo ABBBAAAABBBBBABBABBBABBB | \ perl -pe 'BEGIN { binmode \*STDOUT } chomp; tr/AB/\0\1/; $_ = pack "B*", $_' | \ od -tx1 0000000 70 fb 77 0000003 The above reads input one line at a time. It's up to you to make sure the lines are exactly what ...


5

I know you asked for a mv solution, however, despite the warning, this can be easily done with rename (in the Perl package): ~/tmp$ touch foo ~/tmp$ rename 's/$/\nbar/' foo Unsuccessful stat on filename containing newline at /usr/share/perl5/File/Rename.pm line 69. ~/tmp$ ls foo?bar


4

On a GNU system, you can use the ' flag of GNU printf: $ stat -c"%A %h %U %G %'s %n" /bin/foo -rw-r--r-- 1 root root 45,112 /bin/foo This is documented in man 3 pritnf: ' For decimal conversion (i, d, u, f, F, g, G) the output is to be grouped with thousands' grouping characters if the locale information indicates any. Note that ...


4

People usually want to see what they're typing (unless it's a password) :-) The terminal accepts input at any time, and buffers it until an application reads it. More than that, when the tty is in cooked mode, the kernel buffers whole lines at a time and provides some rudimentary line editing functionality that allow you to kill the entire buffered line ...


4

Assuming bash, and also assuming both files are sorted: join -a1 <(sed 's/./& /6' input.txt) mapping.txt | sed 's/ //g; s/|$/|B00\/0000/' Output: 100180011|225|L08/2015 100180011|226|L08/2015 100181111|201|B00/0000 100181111|202|B00/0000 103823004|011|A06/2012 103823004|011|J02/2012 103823004|011|J03/2012 103823004|012|A06/2012 ...


4

One aspect of this problem isn't really about awk - and only a little bit about the shell. The problem is that on a standard, canonical tty most of the time the kernel's tty discipline is buffering your input - just echoing it to your screen and nowhere else - so that it can efficiently handle backspacing and such-like. However, when you press return or ...


3

Assume that you have a file named input, you want to remove all line start with # in input. You can get all lines don't start with # using: grep -v '^#' input But how do you make changes to input? With standard POSIX toolchest, you need to use a temporary file, some thing like: grep -v '^#' input >/tmp/input.tmp mv /tmp/input.tmp ./input With shell ...


3

The only option POSIX defines is -R. Some implementations of cp, most notably the one by GNU, provides -r (as well as --recursive) as an alias. The author of the tutorial you’re reading is probably using some GNU system, and used -r, but you should be absolutely fine using -R yourself; and since it is more portable, I would actually recommend getting used ...


3

Apple's package management system is often subject to criticism. The utility pkgutil can be used to list and query the package receipts. List all the packages installed with Apple's installer pkgutil --pkgs Regex for a package id pkgutil --pkgs=.\+Xcode.\+ List all the files in a package id pkgutil --only-files --files ...


3

ls -a -l is what you meant. Unix arguments must be space separated or combined into a single argument, as in ls -al. In fairness, your style would be legal on the DOS prompt, where you don't need spaces before /-delimited options (e.g., DIR/D/B is fine). But Unix is not DOS... fortunately.


3

For large files using sort will be slow. I wrote a short C program to solve the equivalent problem (see this gist for Makefile with tests): #include <stdio.h> #define BUFFERLEN 4096 int main(){ // This program reads standard input and calculate frequencies of different // bytes and present the frequences for each byte value upon exit. // ...


3

I am going to suggest a solution which will not solve all of your problems, but will help you to switch way way faster!! The solution is using autojump. Install it on Mac using: brew install autojump Then, what autojump does is it remembers all of your directories you visited previously. It keeps score for various directories, so that the directory ...


3

I will add another option/trick. It uses symbolic links, these are very useful. They are a bit like short-cuts but, in most ways, better (except where short-cuts are used as wrapper scripts, in which case wrapper scripts are better). It also uses bash's CDPATH variable. cd ~ mkdir drive-letters cd drive-letters ln -s / c: ln -s "$HOME" h: ln -s ...


3

I'm pretty sure you can just do: cat ./tmp[12] | sed -f - ./wrong_file >outfile At least, that will not cause any issues if all of sed's script instructions are specific to line number. There's no need to apply the scripts separately - you can chain them all together and run the script at once. That you have to do this at all, though, is indicative of ...


3

With pdftk and GNU coreutils Determine the number of pages in the PDF file, then call shuf to generate a randomized list of page numbers, and call pdftk again to extract the given sequence of pages. pdftk original.pdf cat $(shuf 1-$(pdftk original.pdf dump_data | awk '$1=="NumberOfPages:" {print $2}')) output randomized.pdf With Python and PyPdf ...


3

You haven't set window active background color, you only set active panel border, try: set-window-option -g window-status-current-bg red


3

{ printf '2i[q]sq[?z0=qPl?x]s?l?x' tr -dc AB | tr AB 01 | fold -b24 } <infile | dc In making the following statement, @lcd047 has pretty well nailed my earlier state of confusion: You seem to be confused by the output of od. Use od -tx1 to look at bytes. od -x reads words, and on little endian machines that swaps bytes. I didn't follow ...



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