LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-29-2009, 05:24 AM   #1
tatoosh
LQ Newbie
 
Registered: Jul 2009
Posts: 13

Rep: Reputation: 1
windows: executeable > filename.txt


How to do so in linux (centos):

In dos-console i can write output to a file with this example:

dir > filename.txt

when i do this in linux:

postmap filename > filename.txt


the filename.txt will be created but with 0 bytes (=empty)
 
Old 07-29-2009, 05:35 AM   #2
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,464

Rep: Reputation: Disabled
No problem for me.
Code:
@Attila:~/Catfon$ ls
catfon35  estel04.gif  src  TIRP.TTF
jdkaye@Attila:~/Catfon$ ls > dir.txt
jdkaye@Attila:~/Catfon$ cat dir.txt
catfon35
dir.txt
estel04.gif
src
TIRP.TTF
I assume you meant something like this.
Did you really mean to type postmap? I have portmap (must be run as root) but not postmap.
cheers,
jdk

Last edited by jdkaye; 07-29-2009 at 05:38 AM.
 
Old 07-29-2009, 05:39 AM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally Posted by tatoosh View Post
How to do so in linux (centos):

In dos-console i can write output to a file with this example:

dir > filename.txt
Works in Linux to, Linux is just way more powerful and
versatile, but that comes at a price/cost: learning.

Quote:
Originally Posted by tatoosh View Post
when i do this in linux:

postmap filename > filename.txt


the filename.txt will be created but with 0 bytes (=empty)
Depends on what postmap does. Do you see anything when
you run it w/o redirection? If you run it with the re-direct,
do you still see something?

In that case it's probably debug/error output, and that's
not on STDOUT but on STDERR. Try postmap filename 2> filename.txt



Cheers,
Tink
 
Old 07-29-2009, 05:44 AM   #4
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,263

Rep: Reputation: 297Reputation: 297Reputation: 297
Some programs write output to "stderr" instead of regular "stdout". These are different, since there then is a way to display error messages even if the output is redirected.

So for example:

java -version >javaversion.txt

This does not work, at least with Sun Java, since it's outputting to stderr.

java -version &>javaversion.txt

This means send both regular output and error output to the file. This works as expected.
 
Old 07-29-2009, 05:48 AM   #5
tatoosh
LQ Newbie
 
Registered: Jul 2009
Posts: 13

Original Poster
Rep: Reputation: 1
yes i meant postmap

ok that works with "2>".

thanks alot.

now my output file looks like:
postmap: warning: mymails_allowed.db: duplicate entry: "mymail@test.com"

how can i remove all content execpt the mail address, so my output file will be:

mymail@test.com
othermail@here.com
...
 
Old 07-29-2009, 05:59 AM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Untested (no postfix here):
Code:
postmap filename 2>| sed -r 's/^.*"(.*@.*)"$/\1/' > filename.txt
 
Old 07-29-2009, 06:10 AM   #7
tatoosh
LQ Newbie
 
Registered: Jul 2009
Posts: 13

Original Poster
Rep: Reputation: 1
got it with:
| awk '{print $6}' | tr -d "\""

thx for helping !!
 
Old 07-29-2009, 06:17 AM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally Posted by tatoosh View Post
got it with:
| awk '{print $6}' | tr -d "\""

thx for helping !!
Welcome :}

With awk you could save yourself the extra tr ...
Code:
awk -F"[ \"]" '{print $7}'
Admittedly hardly shorter, but it saves you one
extra process ...
 
Old 07-29-2009, 06:45 AM   #9
tatoosh
LQ Newbie
 
Registered: Jul 2009
Posts: 13

Original Poster
Rep: Reputation: 1
ok thanks!
now i need only the first line and did it with 'head'

how to write the head output in a variable?
example:
$myvar=head -1 1.txt

doesnt work
 
Old 07-29-2009, 07:31 AM   #10
vonbiber
Member
 
Registered: Apr 2009
Distribution: slackware 14.1 64-bit, slackware 14.2 64-bit, SystemRescueCD
Posts: 420

Rep: Reputation: 86
Quote:
Originally Posted by tatoosh View Post
ok thanks!
now i need only the first line and did it with 'head'

how to write the head output in a variable?
example:
$myvar=head -1 1.txt

doesnt work
1. to assign a value to a variable:
myvar=...
(and not $myvar=...)

2. to store the contents of 1st line into the 'myvar' variable:
myvar="$(head -n1 1.txt)"

then to display the value of myvar variable:

echo "$myvar"
 
Old 07-29-2009, 07:51 AM   #11
tatoosh
LQ Newbie
 
Registered: Jul 2009
Posts: 13

Original Poster
Rep: Reputation: 1
ok thx again
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Standalone executeable file m_anzaralam Linux - Newbie 2 03-05-2009 02:10 AM
cat onelinefile.txt >> newfile.txt; cat twofile.txt >> newfile.txt keep newline? tmcguinness Programming 4 02-12-2009 07:38 AM
Can Perl do this? "sed -ie '3d' filename.txt" gctaylor1 Programming 2 08-29-2008 07:42 PM
grep from filename.txt can't get the whole line papasj Programming 3 02-25-2008 01:38 PM
using commands to output path, filename and info to a txt file bob_man_uk Linux - General 3 05-11-2006 03:31 PM


All times are GMT -5. The time now is 12:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration