tr command behaving unexpectedly


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting tr command behaving unexpectedly
# 1  
Old 06-23-2009
tr command behaving unexpectedly

Im trying to execute the below command on our server to list files and replace the newline in the file list with spaces, but the character 'n' is getting replaced with a space, is there any environment variable that needs to be set in UNIX?


sh -c 'ls -trx /data/inbound/drm/DRM_PRCC_Category_Flat*.txt /data/inbound/drm/DRM_PRCG_Group_Flat*.txt | tr "\n" " " '

gives the output

Output from command ====>
/data/i bou d/drm/DRM_PRCC_Category_Flat_20090617_113245.txt
/data/i bou d/drm/DRM_PRCG_Group_Flat_20090617_113319.txt

I expect the output to be
/data/inbound/drm/DRM_PRCC_Category_Flat_20090617_113245.txt /data/inbound/drm/DRM_PRCG_Group_Flat_20090617_113319.txt


Funnily the same command is working fine on 3 other servers.

Is there any environment variable that needs to be set or any of the LC_ env variables that hav eto be changed?

Regards
Ramesh
# 2  
Old 06-24-2009
You can use sh -c
Code:
'ls - trx /data/inbound/drm/DRM_PRCC_Category_Flat*.txt /data/inbound/drm/DRM_PRCG_Group_Flat*.txt |tr -d '\n'
or
tr -s '\n' ' '
if you want space in between.

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

[Solved] wc behaving weirdly

Can anyone explain why wc is behaving weirdly? Their are only 2 occurrences but wc thinks their are 7 occurrences. I have even manually checked this. $ grep -i base * lit: base xx lit.lst:003- 00103 BASE XX $ grep -i base * | wc -w ... (2 Replies)
Discussion started by: cokedude
2 Replies

2. Shell Programming and Scripting

awk not behaving as expected

Hi, Immediate help on below will be appreciated. I have to read a file (max of 10MB) which will have no new line characters, i.e. data in single line. and have to inster '\n' at every 100 characters. and if record starts with 'BUCA' then need to pick value of length 10 at position 71 and... (7 Replies)
Discussion started by: maks475
7 Replies

3. UNIX for Advanced & Expert Users

cut command Behaving Differnetly in different Version

Hi, We have few hundered scripts using cut command in thousands of lines. On HP-UX shell script developer used echo "ABCEFG" | cut -c -1-3 to cut first three character of the string. We recently moved to Linux and this command throws error. I think this might be due to different version of... (3 Replies)
Discussion started by: ajazurrahman
3 Replies

4. Shell Programming and Scripting

jobs command behaving differently in script

Here is my test script: #!/bin/sh result=`jobs` echo " Jobs: "$result result=`ls` echo " LS "$result Here is the output: Jobs: LS 0 1 2 3 4 5 6 7 gcd initialize.sh #inter_round_clean.sh# inter_round_clean.sh inter_round_clean.sh~ look parallel_first_run.sh... (3 Replies)
Discussion started by: nealh
3 Replies

5. Shell Programming and Scripting

Grep command behaving strangely

Hi, I need to count number of '$' symbol in a file and assign it to a variable. I am using below command. grep -c '\$' inputfile O/p: 10359 Its giving correct o/p but when I am assigning the same to a variable its giving completely different o/p. ab1=`grep -c '\$' inputfile` $... (3 Replies)
Discussion started by: Opamps123
3 Replies

6. Red Hat

nslookup behaving strangely

I have two servers on same domain. one can nslookup other cannot Psu100 can lookup to psu000, psu010 & psu011 Psu110 can NOT lookup to psu000, psu010 & psu011 I verified resolv.conf entries on both psu000 and psu010 and it contains both name servers (10.200.10.21 & 10.200.11.22).I am... (1 Reply)
Discussion started by: scorohan
1 Replies

7. UNIX for Dummies Questions & Answers

Uniq command behaving odd

My file has k s j v l k a s f l k s a d f j l a s (3 Replies)
Discussion started by: phoenix_nebula
3 Replies

8. UNIX for Advanced & Expert Users

FTP behaving erraneous way

Hi Gurus, I tried FTP one file to UNIX which got values like wel^come If I see the content in unix, it shows like wel^Zcome ^ coverted into ^Z (Control + Z ) Can someone please share what is happening here? Thanks, Shahnaz (5 Replies)
Discussion started by: shahnazurs
5 Replies

9. UNIX for Dummies Questions & Answers

awk command behaving differntly on 2 servers--urgent

Hi I am using awk command for string replacement. I have 2 servers. The command runs perfectly well on 1st server On the second server when i run the command on the same datset The command gets stuck while processing a large piece of record.. Does it have anything to with setting on the 2... (1 Reply)
Discussion started by: aixjadoo
1 Replies

10. UNIX for Advanced & Expert Users

csplit not behaving

I have a large file with the first 2 characters of each line determining the type of record. type 03 being a subheader and then it will have multiple 04 records. eg: 03,xxx,xxxx,xxxx 04,xxxxxxxxxxxxxxxxxxxxxxxxxxxx 04,xxxxxxxxxxxxxxxxxxxxxxxxxxxx 03,xxx,xxx,xxx ... (2 Replies)
Discussion started by: badg3r
2 Replies
Login or Register to Ask a Question