Tag Info

New answers tagged

2

From man ls: -a, --all do not ignore entries starting with . -F, --classify append indicator (one of */=>@|) to entries -h, --human-readable with -l, print sizes in human readable format (e.g., 1K 234M 2G) -l use a long listing format The command ls -alhF is equivalent to ls -a -l -h -F The ability to ...


0

You can use an associative array on awk and then sort: cat access.log | awk ' { tot[$0]++ } END { for (i in tot) print tot[i],i } ' | sort output: 1 c.php 1 d.php 2 b.php 3 a.php


2

i=0 { paste res.? res.?? res.??? while paste ./res."$((i+=1))"[0-9][0-9][0-9] do :; done; } >outfile I don't think this is as complicated as all that - you've already done the hard work by ordering the filenames. Just don't open all of them at the same time, is all. Another way: pst() if shift "$1" then paste "$@" fi set ...


2

It sounds like what you are describing is actually program A running in the background. A process can still print to the terminal even if it is running in the background. A bash example: #----background_program----# #!/bin/bash for ((i=0;i<=10;i++)); do echo "$i" sleep 5 done exit 0 You can run this in the background, see its output popping ...


5

This is called typeahead, and it's not shell specific. What you type ends up being buffered in the terminal, and the next time a program running in the terminal is ready for input it reads what is waiting in the buffer. In your example that program is the shell, so it executes the command you typed as if you'd waited for A to finish before typing it. Some ...


3

In your script file named hexto64, simply write : #!/bin/bash printf "%s" "$1" | xxd -r -p | base64 And then you can use it as such : hexto64 49276d2 Just so you know, $1 means the first parameter you gave after the program name : 49276d2 in our case.


1

Given the amount of files, line sizes, etc. involved, I think it will surpasses the default sizes of the tools (awk, sed, paste, *, etc) I would create a small program for this, it would not have 10,000 files open, nor a line of hundred of thousands in length (10,000 files of 10 (max size of line in the example)). It only requires an ~10,000 array of ...


8

If chaos' answer isn't applicable (because you don't have the required permissions), you can batch up the paste calls as follows: ls -1 res.* | split -l 1000 -d - lists for list in lists*; do paste $(cat $list) > merge${list##lists}; done paste merge* > final.res This lists the files 1000 at a time in files named lists00, lists01 etc., then pastes ...


10

If you have root permissions on that machine you can temporarily increase the "maximum number of open file descriptors" limit: ulimit -Hn 10240 # The hard limit ulimit -Sn 10240 # The soft limit And then paste res.* >final.res After that you can set it back to the original values. A second solution, if you cannot change the limit: for f in ...


2

Try to execute it on this way: ls res.*|xargs paste >final.res You can also split the batch in parts and try something like: paste `echo res.{1..100}` >final.100 paste `echo res.{101..200}` >final.200 ... and at the end combine final files paste final.* >final.res


0

Besides from above answers, you can also use wifi-menu on Arch Linux. It will show a CLI-Based GUI and you can choose a WiFi from WiFi list that is shown. wifi-menu depends on dialog though. You must have it installed first.


1

The $HOME environment variable is commonly set and exported by login to the pathname of a user's home directory when a user logs in. A POSIX-compatible shell will use the value of this environment variable in a context when it should perform a ~ tilde expansion to complete a path to a username's home directory but the actual expanded field is otherwise null. ...


3

What you need isn't an alias, but a function. Aliases do not support parameters in the way you want to. It would end just appending the files, gtkmm simple.cc simple would end like: g++ -o `pkg-config gtkmm-3.0 --cflags --libs` simple.cc simple and that's not what you try to achieve. Instead a function allows you to: function gtkmm () { g++ "$1" -o ...


1

If you want to copy all the .txt files in a directory, use a wildcard pattern: cp direct/direct1/*.txt target This copies all the .txt files that are in the directory direct/direct1 to the directory target (which must already exist). You can pass multiple patterns to copy files from multiple directories: cp direct/direct1/*.txt direct/direct2/*.txt ...


2

In shell, user's home directory is located in /home/username, ~ is shortcut for home directory of the current user using the shell, ~usr is shortcut for home directory of user with username usr, so ~usr is the same as /home/usr. If your username is usr, then ~ and ~usr are the same. The home directory of current user is also saved in variable $HOME.


6

Whatever you're saying about ~$, home$, and /home$ doesn't make much sense.  I guess you're talking about your command line prompt; if so, it would have been useful to show what you typed and what happened (and then explained what you expected). But I can read minds, so I believe that I understand the issue: ~ and ~user239887 (assuming user239887 is your ...


1

Answer: @derobert pointed out the "sox" and "play" command are part of the same package but does different thing. The 3600 below is the time interval in seconds. sox -n note.mp3 synth 3600 sin 347 The above code will generate an hour long tone without playing it. play -n note.mp3 synth 3600 sin 347 The above code will play the tone for an hour AND ...


2

You can use find to only select the `.txt files from under some directory: find direct/direct? -name "*.txt" this would print out all the files, so you can check you got what you wanted, and not too much is going to be selected. The *.txt has to be quoted, otherwise the shell will try expand this to .txt files in the current directory. As for the ...


2

As stated by jpkotta, network-manager is likely the culprit. You can see its status by running ps -aux | grep network-manager | grep <username>. If you get a result, it is running, otherwise it isn't. It will keep overwriting any changes you make with ifconfig as long as it is running. Kill network-manager by running sudo service network-manager ...


4

Probably a limit of the terminal device line discipline internal line editor buffer. You should be able to enter long lines by pressing Ctrl+D in the middle of it (so the currently entered part be sent to cat and the line editor flushed), or by disabling that line editor altogether. For instance, if using zsh: STTY=-icanon cat > file Note that then ...


0

Which shell are you using ? In zsh arguments can be passed something like this - d () { dmesg|grep -iw usb|tail -$1 } alias would always just substitute the short string with the long string.


3

In the case - yes, you can as exception, because you argument is the last in line: alias d='dmesg | grep -iw usb | tail' d -5 should work.


3

Can an argument be passed through the “alias” No. An alias is a simple string-replace. Use functions. d(){ dmesg|grep -iw usb|tail -"$1" }


0

The simplest is to change your current directory to / and execute : du -chs * | sort -h


1

You cannot access files by inodes, because that would break access control via permissions. For example, if you don't have the permission to traverse a directory, then you can't access any of the files in that directory no matter what the permissions on the file are. If you could access a file by inode, that would bypass directory permissions. Thus, while ...


0

You can easily kill a bunch of processes at once if you arrange to run them (and only them) in the same process group. Linux provides the utility setsid to run a program in a new process group (in a new session, even, but we don't care about that). (This is doable but more complicated without setsid.) The process group ID (PGID) of a process group is the ...


0

It should work if you change the ownership and permissions of the device node you've created: chown kalak:kalak node chmod 600 node (assuming your username is kalak, your main group is kalak and your device node is called node).


0

For the record, here's the approach that I prefer: grep pattern $(find . -type f ! -path './test/main.cpp') By keeping the grep at the beginning of the command, I think this is a little more clear -- plus it doesn't disable grep's color highlighting. In a sense, using find in a command-substitution is just a way of extending/replacing the (limited) ...


1

I could write a book : "The lost art of xargs". The find ... -exec … '; launches a grep for each file (but the variant with -exec … + doesn't). Well, we're wasting CPU cycles these days so why not, right? But if performance and memory and power is an issue: use xargs: find . -type f \! -path 'EXCLUDE-FILE' -print0 | xargs -r0 grep 'PATTERN' GNU's find's ...


3

I don't think it's possible with GNU grep. You don't need pipes though. With find: find . ! -path ./test/main.cpp -type f -exec grep pattern {} + With zsh: grep pattern ./**/*~./test/main.cpp(.) (excludes hidden files, just as well to exclude the .git, .svn...).


3

grep can't do this for file in one certain directory if you have more files with the same name in different directories, use find instead: find . -type f \! -path './test/main.cpp' -exec grep pattern {} \+


2

To run commands concurrently you can use the & command separator. ~$ command1 & command2 & command3 This will start command1, then runs it in the background. The same with command2. Then it starts command3 normally. The output of all commands will be garbled together, but if that is not a problem for you, that would be the solution. If you ...


1

If your find supports -path which was added to POSIX in 2008 but still missing in Solaris: find . ! -path ./test/main.cpp -type f -exec grep pattern /dev/null {} +


0

@Costas already gave you the best answer, to replay to your second question But this is very cumbersome and I would like to try to find a way to parse the output from ls -i Simplex_config*.csv and pipe it to another command in a one-liner -- is there such an option available? you can just use xargs: ls -i | cut -d ' ' -f 1 | xargs -I '$input' find ...


3

1. find . -type f -name 'Simplex*.csv' -print0 | xargs -0 cat > looksee.txt From man xargs --null -0 Input items are terminated by a null character instead of by whitespace, and the quotes and backslash are not special (every character is taken literally). Disables the end of file string, which is treated like any other ...


-1

You can use a pipe. This will start the commands on either ends of the pipe at the same time. You should be able to stop all the commands with the CTRL-C too. 1st command | 2nd command | 3rd command If you want to run the commands one after the other, you can use @serenesat's method.


0

You can use the semicolon ; or && like this: cmd1; cmd2 # Runs both the commands, even if the first one exits with a non-zero status. cmd1 && cmd2 # Only runs the second command if the first one was successful.


2

In your scenario, command is reading from its standard input; unless it accepts some other way of providing this information, you need to continue feeding it its input in this way. So if you don't want to use a file, use printf with a pipe: printf "To: me@domain.com\nMessage: Some message" | command


0

Ok. I happened to notice that when ever I started tmux lots of 'other' stuff kept happening. Tracked that down to the fact that tmux likes to start login shells... When I fixed that with adding # DONT create login shell!! set -g default-command "${SHELL}" to my ~/.tmux.conf it fixed both issues. Hope this helps others. Sorry for the whole 'answering ...


0

You need to escape the . so that it does not match any character to make sure it will not match something like "name@add.abr" for example. You can also look for .br that appears after an @. Try sed -i '/".*\@[^"]*\.br"/d' customer.csv Here is an example run: ~$ echo '"Phone Number","EMAIL@XYZ.com","NAME" > "Phone Number2","EMAIL@XYZ.br","NAME2" > ...


0

This will find all files recursively, and sort them by size. It prints out all file sizes in kb, and rounds down so you may see 0 KB files, but it was close enough for my uses, and works on OSX. find . -type f | xargs ls -la | awk '{print int($5/1000) " KB\t" $9}' | sort -n -r -k1


2

This ended up as quite a facepalm moment. I had forgotten to deactivate 'OS Install Mode' in BIOS which limits the RAM to 256MB, among other things I probably did not even notice.


0

The beautiful thing about *nix, and open source in general, is that you have no shortage of resources. Most *nix CLIs will behave similarly, though there are outliers. Don't worry about them for now. Get BASH figured out. It'll be your interpreter 99% of the time. Learn vim, and know right now that most distro's only include vim-tiny, so install the package ...


1

Sure, there are “common Linux commands”, but I doubt that you'll find statistics as to which ones are used most often on average, and different people use different commands. There is no authority who will say “this command is common, this one is not”. There are commands that are standard across Unix-like operating systems, defined by POSIX. However ...


0

This list of the most useful commands and a brief explanation about each one of them would get you started. This list is not tied to any distro box either which is pretty useful. http://ss64.com/bash/


-1

ls -lrth | tail ls -lrth | tail -n 10 ls -lrth | grep *.gz | tail


2

You could use xkill, xdotool or wmctl. type xkill on the terminal and then click on the window you want to close.


0

If performance is not the concern (as in the question that was closed as a duplicate of this one), and you want to list the first n files (as opposed to the first n lines of the output of ls) in the list of files sorted by filenames, with zsh, you can use: ls -ld -- *([1,4]) to list the first 4 files. zsh will still read the full content of the directory ...


1

I just did such a conversion starting from Marco's solution. I added changing the file extension, in my case, from .mp4 to .mp3: #!/bin/bash for i in *.mp4; do ffmpeg -i "$i" -codec:a mp3 "mp3/${i%.mp4}.mp3";done


0

You can always use the page title for name convention, so it should be unique. Given file with list of addresses, here is the one-liner: while read url; do wkhtmltopdf $url "$(curl -s $url | grep -o "<title>[^<]*" | tail -c+8).pdf"; done < urls.lst where urls.lst is your file with list of urls.



Top 50 recent answers are included