Re: OT: bashfråga

Andreas Ronnquist <[email protected]>
Newsgroups gmane.linux.debian.user.swedish
Message-ID <[email protected]>
On Mon, 30 Mar 2015 15:59:46 +0200,
[email protected]<[email protected]> wrote:

>Jag behöver en fil som innehåller en datumsträng utan LF i slutet.
>Skulle naturligtvis kunna skriva ett C-program som ger mig exakt det
>men jag skulle vilja göra det i ett bash-script.
>
>Nedanstående fungerar men det känns väldigt yxigt, speciellt
>sed-kommandot. Någon som har ett bättre förslag?
>
>date +"%Y%m%d_%H%M%S" > tmp
>sed s/\
>// tmp > NEWDATE 2> /dev/null
>

Du skulle kunna använda tr:

date +"%Y%m%d_%H%M%S" | tr -d '\n'

http://lists.gnu.org/archive/html/bug-coreutils/2007-08/msg00026.html

-- Andreas Rönnquist
[email protected]
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.