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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
05-11-2017, 04:22 AM
|
#1
|
LQ Newbie
Registered: Jul 2012
Location: Singapore
Distribution: RedHat, Fedora, SuSE
Posts: 8
Rep:
|
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
|
|
|
05-11-2017, 06:55 AM
|
#2
|
Member
Registered: Jan 2017
Location: Fremont, CA, USA
Distribution: Trying any&ALL on old/minimal
Posts: 997
|
Try -d\\n or -d\\12 or -d\\xa See man printf. I think the shell "eats" the first backslash. Experiment using echo.
|
|
|
05-11-2017, 06:57 AM
|
#3
|
LQ Guru
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
|
It's treating the \n as a literal 'n'.
Try:
|
|
|
05-11-2017, 09:00 PM
|
#4
|
LQ Newbie
Registered: Jul 2012
Location: Singapore
Distribution: RedHat, Fedora, SuSE
Posts: 8
Original Poster
Rep:
|
Quote:
Originally Posted by !!!
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
|
|
|
05-11-2017, 09:01 PM
|
#5
|
LQ Newbie
Registered: Jul 2012
Location: Singapore
Distribution: RedHat, Fedora, SuSE
Posts: 8
Original Poster
Rep:
|
Quote:
Originally Posted by hydrurga
It's treating the \n as a literal 'n'.
Try:
|
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
|
|
|
05-12-2017, 11:25 AM
|
#6
|
LQ Veteran
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: Rocky 9.4
Posts: 5,801
|
Quote:
Originally Posted by tprabhu1983
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.
|
05-13-2017, 10:49 AM
|
#7
|
Member
Registered: Jan 2017
Location: Fremont, CA, USA
Distribution: Trying any&ALL on old/minimal
Posts: 997
|
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 11:00 AM.
|
|
|
05-14-2017, 09:19 AM
|
#8
|
LQ Newbie
Registered: Jul 2012
Location: Singapore
Distribution: RedHat, Fedora, SuSE
Posts: 8
Original Poster
Rep:
|
Quote:
Originally Posted by !!!
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.
|
All times are GMT -5. The time now is 09:42 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|