printing backslashes


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers printing backslashes
# 1  
Old 02-19-2012
printing backslashes

Code:
printf "\\"

prints a backslash.how we can print multiple backslashes such as "\\\\\\\\\\\\\\\\\\\\".
Thanks
# 2  
Old 02-19-2012
Code:
for i in {1..10}; do printf "\\"; done

Code:
perl -e 'print "\\" x 10'

This User Gave Thanks to balajesuri For This Post:
# 3  
Old 02-19-2012
So, it's not possible to achieve without a loop(i.e in a single printf())?

thanks
# 4  
Old 02-19-2012
Quote:
Originally Posted by pandeesh
So, it's not possible to achieve without a loop(i.e in a single printf())?

thanks
Yes, it is possible.
Code:
printf "\\\\\\\\\\\\\\\\\\\\"

or

Code:
printf -v backslash '%*s' 20; echo ${backslash// /\\}

or
Code:
eval printf -v backslash '%.0s\\' {1..20}; echo ${backslash}

# 5  
Old 02-19-2012
Use single quotes:

Code:
$ printf "%s\n" '\\\\\\'
\\\\\\

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to add backslashes to end of certain lines of text

I'd like to write up notes in a relatively readable format and then use a shell script to add LaTeX formatting. Specifically, I'm trying to figure out how to add the LaTeX newline character (\\) to the end of lines without \begin{} or \end{} statements example notes file: \begin{enumerate} --... (2 Replies)
Discussion started by: icskittles
2 Replies

2. UNIX for Dummies Questions & Answers

Sco Unix printing : jobs hangs in queue - printing via lp versus hpnpf

Hi, We have a Unix 3.2v5.0.5. I installed a printer via scoadmin, HP network printer manager with network peripheral name (hostname and ipadres are in /etc/hosts). This is the configuration file : Code: root@sco1 # cat configurationBanner: on:AlwaysContent types: simpleDevice:... (0 Replies)
Discussion started by: haezeban
0 Replies

3. Windows & DOS: Issues & Discussions

Linux to Windows Printing: PDF starts printing from middle of page.

We are using Red Hat. We have a issue like this: We want to print from Linux, to a printer attached to a Windows machine. What we want to print is a PDF. It prints, but the printing starts from the middle of the page. In the report, there is no space at the top but still printing starts from the... (5 Replies)
Discussion started by: rohan69
5 Replies

4. Shell Programming and Scripting

escaping backslashes to evaluate paths

Hi there, i am struggling with this one, basically i want to replace an existing path string in a file with a new one, but the new one contains slashes which causes problems with "sed", i thought i could change the replacement string into a variable but of course when the variable is evaluated... (4 Replies)
Discussion started by: surfbus78
4 Replies

5. Shell Programming and Scripting

Replacing 3 backslashes with 2 in a string

Hi, I have a requirement where i need to replace 3 backslashes with 2 in the below mentioned string, but i am facing problem with backslashes. However i tried the option below but doesnt work. My input remains a constant as i receive it from my upstream. Input String= "-rfile... (3 Replies)
Discussion started by: kk_madrid
3 Replies

6. UNIX for Dummies Questions & Answers

Inserting commas and replacing backslashes with commas

Hi, Newbie here. I have a file that consists of data that I want to convert to a csv file. For example: Jul 20 2008 1111 / visit home / BlackBerry8830/4.2.2 Profile/MIDP-2.0 Configuration/CLOC-1.1 VendorID/105 Jul 21 2008 22222 / add friend / BlackBerry8830/4.2.2 Profile/MIDP-2.0... (3 Replies)
Discussion started by: kangaroo
3 Replies

7. UNIX for Dummies Questions & Answers

Backslashes in Filenames

Using a small script, I automatically generated some text logs. The files ended being undownloadable, unopenable and undeletable. Upon further investigation, the files ended up looking like this: log\r log2\r log3\r I've tried a few different things, including double slashing before the... (6 Replies)
Discussion started by: shepherdsflock
6 Replies

8. Shell Programming and Scripting

Trouble with Backslashes

Hi folks, there are windows device names in the sixth column of a comma separated file. A example device name is: \\.\Tape0 I don't get the all string in to a variable, because of the preceding backslash. The first backslash is just cut off and my attempts to manipulate the string afterward... (0 Replies)
Discussion started by: wibo1
0 Replies

9. Shell Programming and Scripting

How to echo 4 backslashes more easy ?

How to echo 4 backslashes more easy ? I can use 16 to echo 4 backslashes. # echo \\ \ # echo \\\\ \ # echo \\\\\\ \\ # echo \\\\\\\\ \\ # echo \\\\\\\\\\ \\\ # echo \\\\\\\\\\\\ \\\ # echo \\\\\\\\\\\\\\ \\\\ (4 Replies)
Discussion started by: sun-guy
4 Replies

10. UNIX for Advanced & Expert Users

Printing Problems in unix ... ( Bar-cdoe - Ip Printing)

Hi guys ... i need ur help with some printing problem in unix ... first prob. : i wanna print from my NCR unix to an Win NT , Ip based printing server ( HP JetDirect ) . My issue , is it possible to print directly to an Ip address from unix ? How do i make it work to get any results ?... (3 Replies)
Discussion started by: QuickSilver
3 Replies
Login or Register to Ask a Question