Tag Info

New answers tagged

2

the answer from Poisson Aerohead is basically good , with a small modification that we have better use NULL as filename delimetre . to do this in one command we just change the -print to the -delete . be careful the -delete switch have to be the last switch , or files get deleted before they are checked against other remaining switches . find ...


1

Also short and sweet: cat list | xargs rm This assumes that you have a file named 'list' of all the malicious .php files and that you are in the directory containing the .php files (just to be clear, but I bet you already understood that). If any of the filenames contain newlines, this will be dangerous to run, particularly because you already know they ...


0

You can do this with cp and rm, but without copying the massive amount of data you are (presumably) trying to avoid transferring. @mattdm alluded to this in his comment, and an answer for another question has a more complete discussion about various options. cp -rl source destination rm -r source Essentially, the -l option for the cp command creates hard ...


0

This question has been also very well covered on Stackoverflow. eval `ssh-agent -s` ssh-add


3

Use find for that: find . ! -name '.*' ! -type d -exec rm -- {} +


0

try something like: find <path> ! -name '.*' -type f -exec rm {} \;


1

Try to use this command (you will get the idea) cd folder; zip -r ../zipped_dir.zip * Maybe there is other way, but this is fastest and simplest for me :)


0

So I'm an Amazon AWS customer and I found the simplest solution was to move away from Amazons home grown AMI version and to install the latest version of CentOS. After migrating to CentOS, the missing dependencies we're no longer a factor.


1

A recent version of ss should also display UDP listeners in that way. You can limit to UDP with ss -unlp. I have tried a recent Debian version where ss --version reports ss utility, iproute2-ss140804 and that does work. On A Red Hat 5 system with ss utility, iproute2-ss061002 it doesn't. You do get more info there using ss -aunp although that also shows ...


2

With zsh: vi ./**/*_test.mov(.s:_test.mov:_info.txt:)


0

You need something like find . -name "*.mov" -exec grep test {} + | sed -n 's/^\([^:]*\):.*$/\1/p' | xargs -d \\n -n 1 $EDITOR for opening one file at a time or find . -name "*.mov" -exec grep test {} + | sed -n 's/^\([^:]*\):.*$/\1/p' | xargs -d \\n $EDITOR for opening them simultaneously (assuming the file names do not contain a colon)


0

I wrote a program recently called Setdown that does Set operations from the cli. It can perform set operations by writing a definition similar to what you would write in a Makefile: someUnion: "file-1.txt" \/ "file-2.txt" someIntersection: "file-1.txt" /\ "file-2.txt" someDifference: someUnion - someIntersection Its pretty cool and you should check it ...


2

A simple loop will do the trick. cd working for dir in */*/; do [ -e "$dir/files.zip" ] || # skip directories where the zip already exists ( cd -- "$dir" && zip -r files.zip .) done Note that zip is smart enough to skip the zip file that is being built when recursing in that directory. Some other archiving programs would attempt to stuff the ...


4

You can use this command: awk '{print $1}' filename > newfile where filename is the name of the original big file and newfileis the file that will get the results.


1

Your script does not preserve quotes. The original line executed by completion is: git --git-dir=.git for-each-ref '--format=%(refname:short)' refs/tags refs/heads refs/remotes by your script you get: bash -c '/usr/bin/git --git-dir=.git for-each-ref --format=%(refname:short) refs/tags refs/heads refs/remotes' Note the missing quotes around: ...


1

Simple awk thing. Using some ANSI sequences for movement and clearing... #!/usr/bin/awk -f BEGIN { print "Stats:\n---------------------------------" } function clear() { for (k in ar) printf "\r\033[K\033[1A" } function stats() { for (k in ar) printf "%-10s: %d\n", k, ar[k] } /./{ clear() if (!ar[$0]) ar[$0]=1 ...


1

Here's a small Python 2 program that does what you want. The words are listed in chronological order of first appearance, i.e., each new word is added to the bottom of the list, but it would be easy to sort words alphabetically, or in order of number of occurrences. The output could be a little neater, eg if you know the maximum string length then the ...


3

To expand on what @Bratchley said in the comments, if you have your program's output printing to a file, then you can run then watch command in the terminal to get near-real-time view of the output by including the -n flag like so: watch -n 0.1 "cat yourprograms.log | sort | uniq -c | sort -rn" Note: The ' -n ' flag sets the refresh interval. The ...


-1

I ralize its too late, but the OP's command line was almost correct. He just needed the $ in front of his TAB ('\t') grep -o $'\t' infile | wc -l does exaclty what he was after.


1

With awk, it's awk -F '|' -v OFS='|' '{sub(/^.../, "& ", $4); print}' file But that cannot edit in-place, so you have to: t=$(mktemp) awk -F '|' -v OFS='|' '{sub(/^.../, "& ", $4); print}' file > "$t" && mv "$t" file With sed, sed -i 's/^[^|]*|[^|]*|[^|]*|.../& /' file If you want to validate the postal code, then sed -i ...


1

If you handle the True > true as mentioned elsewhere and get the jq tool, you can just do: jq '{tags}' <infile For example, after copying one of your examples to my clipboard: xsel -bo | sed 's/True/true/g' | jq '{tags}' OUTPUT: { "tags": { "type": [ "char" ], "dynamic": true } }


1

First of all, change True to true. As a whole, this works very well: #!/usr/bin/python import sys import json inputfile = sys.argv[1] with open(inputfile,'r') as myfile: obj = json.loads(myfile.read().replace('True','true')) if "map" in obj: del obj["map"] json.dump(obj,sys.stdout,indent=4,separators=(',',': ')) This writes to ...


0

I found same error: parse error: Invalid numeric literal at line 5, column 26 and I'm not used to json but I think True should be in smallcase, as true, so you can run a perl one-liner to fix it and then use jq to filter out the map key, like: perl -pe 's/(\W)T(rue)/$1t$2/g' file1.json | ./jq 'del(.map)' for first example, that yields: { "tags": {} ...


0

Assuming you have to permissions to (or can convince your SysAdmin), I suggest looking into tmux which is a terminal multiplexer. Tmux allows you to do everything you are talking about and more. You can have it manage all your windows and just detach your session when done. Picking up were you left off is as easy as reattaching to your detached session (one ...


0

This is just a followup of @user17591 solution -- vim scripting: #!/usr/bin/vim -ns :%s%^+ %+++ :%s%^- %--- :%s%^ % :set nu :let html_use_css=1 :so $VIMRUNTIME/syntax/2html.vim :wq :qa! chmod it and Usage: htmlvim file (to produce file.html)


0

For those who have a command that is written on the assumption that piped output will never have color (e.g. some testing frameworks) you may find it useful to use the script utility to first save the ansi output. This can then be pushed to aha or the other utilities mentioned.


1

Due to all help, I could find out how to fix this. The main issue is due to the UTF-8 encoding, the server didn't have it configured as said in comments. Quoting comments: [@Rmano]: In UTF-8 ñ is a two-bytes char [@jimmij]: backspace character for some reason deletes only one of them [@aecolley]: Try setting the environment variable LANG to C.UTF-8 ...


3

You could use nohup combined with &: nohup cf logs broker-analytics > /var/www/cfbrokerlogs/message.log & The nohup command causes the program to ignore hangup signals (i.e. those that are sent when closing the terminal), and the & of course runs it in the background. If you want to make sure it's still running or kill it, you can use ps: ...


0

Use of command substitution as answered by John1024 is be best way to solve this problem. Alternatively, you can pipe your output to while read, which will assign each space-separated value to a variable of your choosing. This is usually used when your output has more than one variable you'd like to use. cat /proc/zem0 |grep -i isrs|grep -Eo '[0-9]+$' | ...


3

Here it is as one command: echo $(( (2147483633 - $(grep -i isrs /proc/zem0 | grep -Eo '[0-9]+$') )/5184000 )) How the simplification was done First consider this pipeline: cat /proc/zem0 |grep -i isrs` This can be simplified to: grep -i isrs /proc/zem0 Thus, the whole of the first command becomes: grep -i isrs /proc/zem0 | grep -Eo '[0-9]+$' ...


10

Sometimes an alias isn't powerful enough to easily do what you want, so here's a way without using them. In some file that is sourced when your shell starts (e.g. .bashrc), add the following function: ls () { echo "Hello world!" command ls } Unlike an alias, a function can recurse. That's why command ls is used instead of ls; it tells your shell ...


3

Not the issue of ls. It's how symlinks work. The .. gets you into the parent of the current directory, the directory doesn't know you got to it through a symlink. The shell has to intervene to prevent this behaviour. For the shell builtin cd, there is special handling that doesn't just call chdir but memorizes the full directory path and tries to figure out ...


0

Since you tagged your question with zsh I assume we are talking about this shell. Most probably you have set (either directly or indirectly with some external script like oh-my-zsh) the variables CHASE_LINKS and/or CHASE_DOTS. To confirm that run setopt | grep -i chase and see if they are listed. If they are, just unset them: unsetopt CHASE_DOTS unsetopt ...


3

If on a GNU system, from man cp: -T, --no-target-directory treat DEST as a normal file This allows you to write cp -rT /home/username/A/ /usr/lib/B/ to do exactly the right thing.


6

advanced cp cp -r /home/username/A/. /usr/lib/B/ This is especially great because it works no matter whether the target directory already exists. shell globbing If there are not too many objects in the directory then you can use shell globbing: mkdir -p /usr/lib/B/ shopt -s dotglob cp -r /home/username/A/* /usr/lib/B/ rsync rsync -a ...


2

Tell cp to copy the directory's contents and not the directory itself: sudo cp -r /home/username/A/* /usr/lib/B/


8

You must not forget to call ls: alias ls='echo "Hello World!"; ls'


3

Compare also: echo '.*[s]' file with echo .*[s] file This outputs the arguments as seen by the command. In your first example you pass your grep command exactly two arguments: the pattern and the file. In your second example your shell will handle the first argument and replace it with all the files starting with a dot and ending in "s". Therefore ...


4

Quotes (either single or double) around an argument inhibit glob expansion. Your first example passes a Regular Expression as an argument to grep. Your second example contains a glob pattern which the shell itself expands, passing filenames that fit that pattern as arguments to grep.


-1

You can use this: cat $(find Directory/ -not -name *.htaccess)


0

Removing my original response (thanks Michael). If no Makefile is created after configure, then it did not finish properly (often a dependency[1] is the problem). configure will always drop two files in the directory it is executed in that you should look at: config.log config.status Take a look at those and see if you can find the problem. From there ...


1

The step ./configure normally reads Makefile.in and writes Makefile. Something went wrong in running it. Run it again and read the output looking for errors. If that fails, read config.log where you might find a clue about what went wrong.


2

I would say that step 3 (Configuring) has failed. Didn't you got any error at step 3? (For the third step you need glibc also installed, make sure you have this). Furthermore, why don't you use the package management? Like apt-get install valgrind? Which distro are u using?


1

If the script needs to access the history, insert an alias into the .bashrc. I have this for the command auto which has an option to repeat the latest command, ad infinitum, depending on changes in the provided commandline arguments. The alias: auto = 'history | auto' Assuming that some_command_to_test depends on input.py and output.py I use this to ...


3

You have a terminal (or terminal emulator) which understands multibyte encodings (probably UTF-8), but a shell which doesn't. Try setting the environment variable LANG to C.UTF-8. Or run locale -a to find another likely value to try.


1

You might be looking for recordmydesktop. You can get a window id using wmctrl or xwininfo and then use that id: recordmydesktop --windowid <id_of_window> you can use --pause-shortcut to define a key combination for pause/continue.


2

The way you are doing this, with compressing a .tar file the answer is for sure no. Whatever you use for compressing the .tar file, it doesn't know about the contents of the file, it just sees a binary stream, and whether parts of that stream are uncompressable, or minimally compressible, there is no way this is known. Don't be confused by the options for ...


1

Yea you would be disconnected. Like Celada say "Connecting to the console is the only safe way!". You can try this and if you can't reconnect with ssh, you can go to your console. But if you use the command: ifdown <interface-name> && ifup <interface-name> I think that's gonna be worked (But you gonna be disconnect).


1

The LZ4 algorithm could be an option. It checks if the beginning of a block is compressible and stores it uncompressed if the ratio is low. This sucessfully prevents compression of already compressed files without the need to specify their names. The overall compression ratio is lower compared to the algorithms you mention. But LZ4 is very fast, on the ...


2

Function keys can be interpreted by the window manager or terminal emulator (you'll find that F11, for example, will usually maximize the window) or passed through to the program as VTxxx or ANSI escape sequences. F9 on Linux and Solaris usually sends ESC[20~. Depending on the versions of the software, bash or ksh will interpret this as either 0~ or ~. On ...



Top 50 recent answers are included