LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 05-11-2017, 05:22 AM   #1
tprabhu1983
LQ Newbie
 
Registered: Jul 2012
Location: Singapore
Distribution: RedHat, Fedora, SuSE
Posts: 8

Rep: Reputation: Disabled
What is the syntax to use octal number in xargs for delimiter argument?


man xargs:
--delimiter=delim, -d
The specified delimiter may be a single character, a C-style character escape such as \n, or an octal or hexadecimal escape code. Octal and hexadecimal escape codes are understood as for the printf command.

The reason is:
Actual Input:
[root@rhel5 ~]# xargs -d\n
No
no
nn

Actual Output:
No
o

Expected Output:
No
no
nn
 
Old 05-11-2017, 07:55 AM   #2
!!!
Member
 
Registered: Jan 2017
Posts: 669

Rep: Reputation: 289Reputation: 289Reputation: 289
Try -d\\n or -d\\12 or -d\\xa See man printf. I think the shell "eats" the first backslash. Experiment using echo.
 
Old 05-11-2017, 07:57 AM   #3
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 19.1 MATE
Posts: 8,018
Blog Entries: 5

Rep: Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872
It's treating the \n as a literal 'n'.

Try:

Code:
xargs -d '\n'
 
Old 05-11-2017, 10:00 PM   #4
tprabhu1983
LQ Newbie
 
Registered: Jul 2012
Location: Singapore
Distribution: RedHat, Fedora, SuSE
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by !!! View Post
Try -d\\n or -d\\12 or -d\\xa See man printf. I think the shell "eats" the first backslash. Experiment using echo.
Thanks for your reply.
With your suggestion, character "n" being saved, but it loses "escape character behaviour" of printing on the next line.

[root@rhel5 ~]# xargs -d\\xa
n1
n2
n3
n4

n1 n2 n3 n4
[root@rhel5 ~]# xargs -d\\12
n1
n2
n3

n1 n2 n3
[root@rhel5 ~]# xargs -d\\n
n1
n2
n3

n1 n2 n3
[root@rhel5 ~]# xargs -d\n
n1
n2
n3

1
2
3
 
Old 05-11-2017, 10:01 PM   #5
tprabhu1983
LQ Newbie
 
Registered: Jul 2012
Location: Singapore
Distribution: RedHat, Fedora, SuSE
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by hydrurga View Post
It's treating the \n as a literal 'n'.

Try:

Code:
xargs -d '\n'
Thanks mate. With the below command, it has lost the "escape character behavior"

[root@rhel5 ~]# xargs -d '\n'
n1
n2
n3
n1 n2 n3
[root@rhel5 ~]# echo 1 \
> 2
1 2
[root@rhel5 ~]# echo 1\
> 2\
> 3\
> 4 |xargs -d\n
1234
 
Old 05-12-2017, 12:25 PM   #6
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.7.1908
Posts: 4,371

Rep: Reputation: 1537Reputation: 1537Reputation: 1537Reputation: 1537Reputation: 1537Reputation: 1537Reputation: 1537Reputation: 1537Reputation: 1537Reputation: 1537Reputation: 1537
Quote:
Originally Posted by tprabhu1983 View Post
Thanks for your reply.
With your suggestion, character "n" being saved, but it loses "escape character behaviour" of printing on the next line.

[root@rhel5 ~]# xargs -d\\xa
n1
n2
n3
n4

n1 n2 n3 n4
[root@rhel5 ~]# xargs -d\\12
n1
n2
n3

n1 n2 n3
[root@rhel5 ~]# xargs -d\\n
n1
n2
n3

n1 n2 n3
[root@rhel5 ~]# xargs -d\n
n1
n2
n3

1
2
3
Typically the defined delimiter is not printed, so yes, it is "lost."
 
1 members found this post helpful.
Old 05-13-2017, 11:49 AM   #7
!!!
Member
 
Registered: Jan 2017
Posts: 669

Rep: Reputation: 289Reputation: 289Reputation: 289
Add -n1
Or try -l
See man xargs. The -d seems to be for processing the input; -n for output.
Let us know, and use ThreadTools at top when resolved.

p.s. I meant: echo \n; echo \\n; echo '\n'; n="\n" echo $n

Last edited by !!!; 05-13-2017 at 12:00 PM.
 
Old 05-14-2017, 10:19 AM   #8
tprabhu1983
LQ Newbie
 
Registered: Jul 2012
Location: Singapore
Distribution: RedHat, Fedora, SuSE
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by !!! View Post
Add -n1
Or try -l
See man xargs. The -d seems to be for processing the input; -n for output.
Let us know, and use ThreadTools at top when resolved.

p.s. I meant: echo \n; echo \\n; echo '\n'; n="\n" echo $n
Perfect answer, thanks mate.

[root@rhel5 ~]# echo 1n 2n 3n |xargs -n1
1n
2n
3n

[root@rhel5 ~]# echo 1n 2n 3n |xargs -l
1n 2n 3n
 
1 members found this post helpful.
  


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
[SOLVED] Convert a number into base 8(octal) in C Program curious95 Programming 24 12-29-2012 06:54 AM
xargs take string as single argument? FireRaven Linux - Software 7 10-10-2011 09:36 AM
One argument version of xargs? adamcannon Linux - Newbie 3 02-06-2008 12:41 PM
Have problem converting a decimal number to octal Linh Programming 4 05-20-2004 04:21 PM
How do I add two octal number ? Linh Programming 3 05-20-2004 04:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:02 AM.

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