Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Clavin June
Clavin June

Posted on

     

Bypassing variable using multi-line cat

TLDR:

Use'EOF'

$cat<<'EOF'>$USER>$(pwd)> `pwd`> EOF$USER$(pwd)`pwd`
Enter fullscreen modeExit fullscreen mode

Sometimes when we want to create a multi-line text and redirect it to the output we will usecat EOF like this

cat<<EOF > /tmp/out line1line2EOF
Enter fullscreen modeExit fullscreen mode

and the result will be like this:

line1line2
Enter fullscreen modeExit fullscreen mode

but if we're gonna pass variables to the line, we're gonna see it works like this:

cat<<EOF > /tmp/out$USER$(pwd)`pwd`EOF
Enter fullscreen modeExit fullscreen mode

output:

clavinjune/tmp/tmp
Enter fullscreen modeExit fullscreen mode

if we want to keep the variables as it is we can use'EOF' instead.

cat<<'EOF' > /tmp/out$USER$(pwd)`pwd`EOF
Enter fullscreen modeExit fullscreen mode

output:

$USER$(pwd)`pwd`
Enter fullscreen modeExit fullscreen mode

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

a bunch of perceptrons
  • Location
    Jakarta, Indonesia
  • Joined

Trending onDEV CommunityHot

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp