Tag Info

Hot answers tagged

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 ...


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 ...


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 {} \+


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" }


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 ...


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 ...


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.


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 ...


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 ...


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


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. ...


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 ...


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 ...


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 ...


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 {} +


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 ...



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