Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #173807
| From | "der.hans" <deb-user@LuftHans.com> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: bash NEWBIE I/O and I/O redirection problems |
| Date | 2016-10-25 05:10 +0200 |
| Message-ID | <sw0hH-8lF-7@gated-at.bofh.it> (permalink) |
| References | <svZEZ-7Nb-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
[Multipart message — attachments visible in raw view] - view raw
Am 24. Oct, 2016 schwätzte Richard Owlett so: moin moin Richard, "to stdout AND "logfile" can be accomplished with tee. # puts the results of ls in the file and also shows results on STDOUT # the -a tells tee to append so repeated calls will get all of the output # from your script ls | tee -a /tmp/ls.out By default tee truncates so without the -a it will first zero out the file, then start adding text. $ rm /tmp/ls.out $ ls -l /etc/issue | tee -a /tmp/ls.out; ls -l /tmp/ls.out -rw-r--r-- 1 root root 26 Nov 30 2014 /etc/issue -rw-r--r-- 1 lufthans lufthans 50 Okt 24 20:06 /tmp/ls.out $ ls -l /etc/issue | tee -a /tmp/ls.out; ls -l /tmp/ls.out -rw-r--r-- 1 root root 26 Nov 30 2014 /etc/issue -rw-r--r-- 1 lufthans lufthans 100 Okt 24 20:06 /tmp/ls.out $ ls -l /etc/issue | tee /tmp/ls.out; ls -l /tmp/ls.out -rw-r--r-- 1 root root 26 Nov 30 2014 /etc/issue -rw-r--r-- 1 lufthans lufthans 50 Okt 24 20:06 /tmp/ls.out $ ciao, der.hans > I suspect an appropriate response would be being pointed an *atypical* > tutorial. > A Google search for "bash tutorial pipe redirect" [w/o quotes] gave results > for "normal" users. I have and odd use case. I had assumed bash as shell but > am open to using another shell if it is more appropriate. > > The following, though using bash syntax, should be considered *PSEUDO* code. > > # stdout and stderr will be a MATE terminal window > # this was required to address a problem outside scope of this post > gsettings set org.mate.media-handling automount false > > > while true > do > echo "Insert medium, press Enter key (or Ctrl+C to end)" > read dummyvar > # need code here for /dev/sr0 to be "ready" - I had been watching drive > activity light > blocks=$(expr $(/sbin/isosize /dev/sr0) / 2048) > echo "Block count: "$blocks ;# to stdout AND "logfile" > echo "Byte count: $(expr $blocks '*' 2048)" ;# to stdout AND "logfile" > DEVICEBLKCOUNT=$(expr $(cat /sys/class/block/sr0/size) / 4) > echo "Device block count: "$DEVICEBLKCOUNT ;# to stdout AND "logfile" > echo "" ;# to stdout AND "logfile" > echo "*********************" ;# to stdout ONLY > echo "The output file will be $FILENAME" ;# to stdout AND "logfile" > xorriso -indev /dev/sr0 -data_cache_size 512 1024 -check_media > data_to=$FILENAME > echo "" ;# to stdout AND "logfile" > echo "next lines are output of ls and isosize commands" ;# to stdout ONLY > ls -l $FILENAME ;# to stdout AND "logfile" > /sbin/isosize $FILENAME ;# to stdout AND "logfile" > echo "about to repeat loop" ;# to stdout ONLY > echo "" ;# to stdout AND "logfile" > done > > -- # http://www.LuftHans.com/ http://www.PhxLinux.org/ # "It's not that I'm so smart, it's just that I stay with problems longer." # -- Albert Einstein
Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
bash NEWBIE I/O and I/O redirection problems Richard Owlett <rowlett@cloud85.net> - 2016-10-25 04:30 +0200
Re: bash NEWBIE I/O and I/O redirection problems "der.hans" <deb-user@LuftHans.com> - 2016-10-25 05:10 +0200
Re: bash NEWBIE I/O and I/O redirection problems "Thomas Schmitt" <scdbackup@gmx.net> - 2016-10-25 09:30 +0200
Re: bash NEWBIE I/O and I/O redirection problems "Thomas Schmitt" <scdbackup@gmx.net> - 2016-10-25 11:30 +0200
Re: bash NEWBIE I/O and I/O redirection problems Richard Owlett <rowlett@cloud85.net> - 2016-10-25 14:20 +0200
Re: bash NEWBIE I/O and I/O redirection problems <tomas@tuxteam.de> - 2016-10-25 11:30 +0200
Re: bash NEWBIE I/O and I/O redirection problems Richard Owlett <rowlett@cloud85.net> - 2016-10-25 14:20 +0200
Re: bash NEWBIE I/O and I/O redirection problems Greg Wooledge <wooledg@eeg.ccf.org> - 2016-10-25 14:10 +0200
csiph-web