I would like to know how to extract a list of unique lines from a text file.
Preferably through Cygwin.
sort -u file > new_file
Your question is somewhat unclear. If you want to eliminate all duplicate lines from a text file you can do something like this:
cat file.txt | sort | uniq
Since the original question referenced Cygwin, which is Windows specific, I'll mention that Luis' answer works just as well using the GNU utilities for Win32 sort. I use the GNU ports off a USB key when I'm working on a machine that I don't want to install Cygwin on, or downloading and installing Cygwin seems like too heavy a solution for the problem I'm trying to solve.
Related
There are two versions of MATLABs (2007a and 2019a) installed on my computer. The 2019a is installed after 2007a so if you use the following code in batch file:
start matlab -r "xxx.m"
The system will call 2019a instead of 2007a.
I searched online and found that most of people say you can call older version by:
start "C:\Program Files (x86)\MATLAB\2007a\bin\win32\MATLAB.exe" -r "xxx.m"
I tried but it give me this error:
if the batch file doesn't include any command ("-r" etc.), it works just fine. MATLAB can be opened without problems.
What's the mistake I made? How could I call older version and have it run some functions?
My OS: Win7
Thanks for all of guys who commented under my question. Turned out there are two ways to do this.
As one of comment said, you just need a pair of "" after start:
start "" "C:\path\MATLAB.exe" -r "xxx.m"
You actually don't need "start", just use directory is fine:
"C:\path\MATLAB.exe" -r "xxx.m"
Both ways solve the problem. A good lesson to learn for starters.
I know this post is old. But I was searching for a solution and found one by myself. The best way is to change the order of the windows environment variables. just put the older version over the newer one and you can use the old script.
I'm trying to refactor classes from my local working copy due to an urgent refactor needed after a bug fix.
So what i am doing is, using cygwin, move to the dir where my exlipse workspace is located and run this query
find . -name "*.java" -exec sed -i 's/bug/big fix/' {} \;
I simply need to replace 1 line of code,
The issue is, that this affects also classes that does not contain tat bug, i see that by looking at the java files in svn, right after running my command on the java files icons in eclipse it appears the brows asterisk appears, and if i run a diff, i see that all lines differs, even though i thought not even one line should be modified.
My local working copy is on a windows file system, any advise?
#Aurand is probably right, it sounds like a line-ending issue. Reset the repo, then add the -b option to sed to preserve line endings.
I'm having some trouble using the pp command to create standalone executables on a Linux machine. It seems that every tutorial says a different thing and I'm a bit confused. I'd like your help regarding two issues:
1. I'm trying to include a module created by me (.pm file), but not sure how to do so and keep getting error messages. Should I use the -M option? or should it be -B? And once the module is included, how do I call it from the script? the usual way (i.e. "use module" and then "module::sub")?
2. I want to include some text files too. So far, I've tried -a and -l options, but not sure if they actually work. Which one should I use? Also, how do I open these files? For instance, if I pack the file tmp.txt, what should the open command look like?
Thank you very much!
Adding modules with the -M option and use the module as usual.
Adding your text file with the -a option, from pp's manual:
By default, files are placed under / inside the package with their original names.
so you should be able to read these text files with:
my $content = PAR::read_file('your_file.txt');
I want to generate a ER Diagram sort of, of my spatial database i created inside of Postgresql. As i am also new to Postgresql, i am not too sure if the diagramming functionality can be done using whats offered by the PgAdmin (not referring to the Graphical Query Builder). However, it seems to me there is none. I read around that there is a perl based tool called postgresql_autodoc that can run through PostgreSQL system tables and return HTML, Dot, Dia and DocBook XML which describes the database. Now this is not exactly what i wanted but its the closest option i have. So i have successfully installed, ActivePerl 5.8 and DBD-Pg 2.10.0 for Perl 5.8 (DBD PG is a Perl DBI driver for the PostgreSQL database) and i have also downloaded the postgresql_autodoc.pl file. I have also added the path for Perl. But when i try to run the postgresql_autodoc.pl via the command prompt, i was getting this error: Possible Unintended Interpolation of #TEMPLATE in string at C:/Perl/bin/postgresql_autodoc.pl line 1831. Global symbol "#TEMPLATE" requires explicit package name at C:/Perl/bin/postgresql_autodoc.pl line 1831. Execution of C:/Perl/bin/postgresql_autodoc.pl aborted due to compilation errors.
I tried to view the postgresql_autodoc.pl using notepad++ however i have no experience with the perl language and so i cant figure out what is really wrong. All i could do is locate line 1831 but i dont know what i should do to fix this problem.
The postgresql_autodoc.pl file was downloaded from: http://www.rbt.ca/autodoc/
I would appreciate if anyone can help me here!
Thanks in advance
Barbara
That thingy, ##TEMPLATE-DIR##, is a string that is replaced when you build and install the module -- meaning you're not supposed to run it directly from the unpacked archive.
Most Perl modules are installed with a more or less simple three-step installation process, something like perl Makefile.PL ; make ; make install. However, this package is slightly different, you seem only to need make install.
Note that I have no experience with installing Perl modules on Windows with ActiveState. So the above may not work (e.g. if there's no make utility which is usually not part of Perl -- though it might be part of the ActiveState Perl distribution).
But there's a workaround. You can simply do what the install script does and replace the ##TEMPLATE-DIR## string yourself. It can be done easily with any text editor by replacing the two occurrences of ##TEMPLATE-DIR## with the path to where the postgresql_autodoc.pl script has been unpacked to -- meaning it's the path the script will look for the *.tmpl files in.
Note that Windows path names can be written with forward slashes in Perl, meaning C:/Temp/postgresql_autodoc should be OK.
I can no longer use / at the windows xp command prompt, and it seems to have started after a botched cygwin installation, e.g. cd /windows won't work, but used to.
Can anyone think of how this might have happened?
OOPS! It doesn't normally work in XP, though I had read that it does in Vista. I simplified my problem and it was wrong. The real problem is:
I was using the cwrsync binaries (meant for cygwin use) that can be used at the command prompt in a way such as:
ssh -i /keydir/keyfile user#server
but after doing something (seems like it was installing cygwin), and even after reinstalling the cwrsync files, I can now only do:
ssh -i \keydir\keyfile user#server, i.e. I have to use the windows convention when referring to local files.
I posted this on the cwrsync forum, but it's not very active, so I was hoping someone might recognize what's going on here, I should maybe try the cygwin forum too.
Actually, since DOS 2.0, the kernel and file APIs have always supported forward slash, and many command line calls. See: http://blogs.msdn.com/larryosterman/archive/2005/06/24/432386.aspx.
I used to go to great pains to detect the OS and use a PATH_SEPARATOR type constant in PHP, when I discovered this by accident (it's use is now considered deprecated, in lieu of a simple "/").
Cheers.
You imagined it - it never worked.
If you happen to be in C:\ and type
C:\>cd /windows
it will take you to C:\WINDOWS\ but that's only because /windows is not a valid option to cd, so it tries ignoring the /.
Forward slash is a path separator in UNIX and cygwin, but Windows uses it for commandline options, eg. dir /w.