I need to insert string to text file,
for example, before first line from the end.
STRINGS=`wc -l $OLDFILE \
| awk '{print $1-1}' \
| sed "s/$DOLLAR/+/g" \
| tr -d \\\n \
| sed "s/+$DOLLAR//" \
| bc`
ADDFILE=$3
head -n $STRINGS $OLDFILE > $NEWFILE
cat $ADDFILE >> $NEWFILE
tail -n 1 $OLDFILE >> $NEWFILE
Can you sugg...
I don't mean a man page or equivalent.
You know how, when you start command line applications with insufficient or invalid command line arguments, they often output a one-liner showing the command line arguments they expected, then quit.
Is there a standard way to write this one-liner? (i.e. Which command line arguments are required, w...
Is there a command line shell or shell customization that supports emacs-style ido find file? In emacs, I can navigate to a directory extremely quickly using C-x C-f and (ido-mode t).
Ideally, I'm looking for a solution that can be used outside of emacs. Though I'd be open for a way to quickly change directories within an eshell buffe...
i have replaced windows shell with my application it worked perfectly, after closing my application i have to launch windows explorer with the following piece of code
Code to start explorer
Process.Start(@"c:\windows\explorer.exe");
Registry key i have used to replace shell
HKEY_Local_Machine\Software\Microsoft\WindowsNT\CurrentVer...
Is it possible for CakePHP to execute a cakephp shell task on background for
i.e running long reports. I would also want to update the current
status back to the user via updating a table during the report
generation and querying using Ajax.
...
Hi mates,
On both, my Cygwin and my Linux box (Debian) I'm experiencing same issue:
I'm working in a shell script with some kind of formatting ids, I want to add a backslash () before a slash occurrence (/).
My sed script is working well at my terminal:
# export someid="314-12345/08"
# echo "${someid}" | sed 's/\//\\\//'
Output:
3...
I've got a source code file, that started as a copy of some sample code from a webpage.
It was created and edited under Windows and compiled with no problems.
But under Mac's I get a load of obscure errors, like:
../MyProgram.cpp:1: error: stray '\255' in program
../MyProgram.cpp:1: error: stray '\254' in program
../MyProgram.cpp:1: er...
I have a bash script that sources contents from another file. The contents of the other file are commands I would like to execute and compare the return value. Some of the commands are have multiple commands separated by either a semicolon (;) or by ampersands (&&) and I can't seem to make this work. To work on this, I created some te...
I want to get diffs on files in a specific pending changelist. I wish I could do this:
p4 diff -c 999
Can someone help me string together some csh magic to make this happen?
Maybe take the output of p4 opened -c 999 and piping it to p4 diff?
...
I want to understand the use of xargs man in Rampion's code:
screen -t man /bin/sh -c 'xargs man || read'
Thanks to Rampion: we do not need cat!
Why do we need xargs in the command?
I understand the xargs -part as follows
cat nothing to xargs
xargs makes a list of man -commands
I have had an idea that xargs makes a list of comm...
I'm trying to create a dictionary of words from a collection of files. Is there a simple way to print all the words in a file, one per line?
...
I'm trying to execute a series of commands using Pythons subprocess module, however I need to set shell variables with export before running them. Of course the shell doesn't seem to be persistent so when I run a command later those shell variables are lost.
Is there any way to go about this? I could create a /bin/sh process, but how wo...
For my debugging needs,pdb is pretty good. However, it would be MUCH cooler ( and helpful ) if I could go into ipython. Is this thing possible?
...
I was inspired by another question to write a script (or rather a one-liner) to grab random Wikipedia pages.
Here's what I've got so far:
# Grab the HTTP header response from Wikipedia's random page link
curl 'http://en.wikipedia.org/wiki/Special:Random' -sI
# Search STDIN for the Location header and grab its content
perl -wnl -e '/Lo...
I am using shell script scp command to move one file from one server to another using ssh.
My command looks like this:
scp -P 23 -i $TEST_SSHKEY $DESTINATION_PATH/$FILETOCOPY $USER_ID@$SERVER_BOX:
File is copying but scp is returning return code as 1.
Why it is happening and what is the solution for this?
...
Hello all,
Is there an option for the CURL command to show only a percentage output to shell rather than all of this, for example:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 12.4M 100 12.4M 0 0 4489k 0 0...
This is what I have so far:
[my1@graf home]$ curl -# -o f1.flv 'http://osr.com/f1.flv' | grep -o '*[0-9]*'
####################################################################### 100.0%
I wish to use grep and only extract the percentage from that progress bar that CURL outputs.
I think my regex is not correct and I am also not sure ...
The GNU/Linux version of cp has a nice --update flag:
-u, --update
copy only when the SOURCE file is newer than the destination file or when the destination file is missing
The Mac OS X version of cp lacks this flag.
What is the best way to get the behavior of cp --update by using built-in system command line programs? I want ...
I was trying to get a list of all python and html files in a directory with the command find Documents -name "*.{py,html}".
Then along came the man page:
Braces within the pattern (‘{}’) are not considered to be special (that is, find . -name 'foo{1,2}' matches a file named foo{1,2}, not the files foo1 and foo2.
As this is part of...
I tend to run my shell in emacs, but when I use it to ssh into another computer this breaks tab-completion. Is there a way to fix this?
...