Hello, I need to print last 20 characters of string, but only whole words. Delimiter is a space "". Let's consider this example:
string="The quick brown fox jumps over the lazy dog"
echo $string | tail -c20
returns s over the lazy dog. And I need it to return over the lazy dog instead. Do you know how to accomplish that...
I often need to fetch tgz files, decompress them, and then delete the tgz.
How can I do all three steps with one simple command?
...
Hello,
I'm using a linux server that display directories in a bold font, and files in a normal font.
e.g. $ ls produces
afile.txt afolder anotherfile.txt anotherfolder
I'd like to use this feature on some other servers. How can it be done? with the .bash_profile?
If anyone has other ideas on how to differentiate folders f...
I bash, how do I convert dos/windows newlines to unix? It must be non-interactive, not like starting vi and typing something in, but a command on the command line that can be put in a script file. The dos2unix and unix2dos commands are not available on the system.
How do I do this with commands like sed/awk/tr?
...
I am writing a little shellscript that needs to go through all folders and files on an ftp server (recursively). So far everything works fine using cURL - but it's pretty slow, becuase cURL starts a new session for every command. So for 500 directories, cURL preforms 500 logins.
Does anybody know, whether I can stay logged in using cUR...
How can I find out where an alias is defined on my system? I am referring to the kind of alias that is used within a Terminal session launched from Mac OS X (10.6.3).
For example, if I enter the alias command with no parameters at a Terminal command prompt, I get a list of aliases that I have set, for example, this is one of them
alia...
How do I create a UNMODIFIED hex dump of a binary file in linux with bash? The od and hexdump commands both insert spaces in the dump, I DON'T WANT THIS, I need something that will simply write a long string with all the hex characters without inserting spaces or newlines in the output. How do I do this in bash?
...
In Bash I can create a map (hashtable) with this common construction
hput() {
eval "$1""$2"='$3'
}
hget() {
eval echo '${'"$1$2"'#hash}'
}
and then use it like this:
hput capitals France Paris
hput capitals Spain Madrid
echo "$(hget capitols France)"
But how do I best iterate over the entries in the map ?. For instance, in J...
I'm on a Mac and I'm trying to make a Vim plugin for compiling/running actionscript files.
First, I need to run mxmlc on the command line, but to do that I have to keep on typing the path to it. Where do I place it so that I don't have to retype the path?
...
I want to make a script that starts a program and then sends it key input. In psuedo-script:
#!/bin/bash
./program << (PRESS CONTROL-Z)
The program is running so if there were additional commands in the script they will not be reached unless say control-z terminates the program.
Is this possible? From what I've found I thought it mig...
I sweated over the question above. The answer I'm going to supply took me a while to piece together, but it still seems hopelessly primitive and hacky compared to what one could do were completion to be redesigned to be less staticky. I'm almost afraid to ask if there's some good reason that completion logic seems to be completely divo...
I'm writing bash script, which does several thing.
In the beginning it starts several monitor scripts, each of them runs some other tools.
At the end of my main script, I would like to kill all things that spawned from my shell.
So, it might looks like this:
#!/bin/bash
some_monitor1.sh &
some_monitor2.sh &
some_monitor3.sh &
do_so...
I have a string like this
BRADI5G20430|BRADI5G20430.1||1
How can I replace the bar (single and multiple) with tab ("\t")?
I tried this but dont' work
sed 's/\|+/\t/g'
I also want to include this line in bash script.
...
How can I do it?
I have a file that looks like this
foo 1 scaf 3
bar 2 scaf 3.3
File2 looks like this
foo 1 scaf 4.5
foo 1 boo 2.3
bar 2 scaf 1.00
What I want to do is to fine lines that co-occur in file1 and file2
when field 1,2,3 are the same.
Is there a way to do it?
...
I have a data that looks like this:
foo foo scaffold_7 1 4845 6422 4845
bar bar scaffold_7 -1 14689 16310 16310
What I want to do is to process the above lines
where I just want to print column 1,2,3, 7 and one more column after 7th.
But with condition when printing column 7 onwards.
Below is my awk script:
awk ...
I want to have such pipe in bash
#! /usr/bin/bash
cut -f1,2 file1.txt | myperl.pl foo | sort -u
Now in myperl.pl
it has content like this
my $argv = $ARG[0] || "foo";
while (<>) {
chomp;
if ($argv eq "foo") {
# do something with $_
}
else {
# do another
}
}
But why the Perl script can't recognize the parameter passed t...
I end up typing
grep -Rni pattern .
and awful lot. How do I make this into an alias like
alias gr='grep -Rni $@ .'
Running that gives:
$ gr pattern
grep: pattern: No such file or directory
Even though the alias looks fine:
$ type gr
gr is aliased to `grep -R $@ .'
It seems that the $@ and the . get swapped when it's actually ...
Under Windows 7 I'd like to change the settings for the Git Bash Here shell extension command window, e.g. width, height and font. But when I do this, I get an error "Unable to modify the shortcut".
I can modify the shortcut for Git Bash in the Start menu by using "Run as administrator..." This works, but only for Bash windows opened fr...
System OSX or Linux
I'm trying to automate my work flow at work, each week I receive an excel file, which I convert to a csv.
An example is:
,,L1,,,L2,,,L3,,,L4,,,L5,,,L6,,,L7,,,L8,,,L9,,,L10,,,L11,
Title,r/t,needed,actual,Inst,needed,actual,Inst,needed,actual,Inst,needed,actual,Inst,neede d,actual,Inst,needed,actual,Inst,needed,actua...
Hi,
I have two large source trees. One of them has some out of date image files. I would like to automatically update all the old image files (png, jpg, gif) in one source tree with the up to date image files in the other source tree.
I am using Windows 7 but I have Cygwin installed. I have tried using rsync so far but with no success...