Sponsored Content
Top Forums Shell Programming and Scripting sed working on command line but file unchanged when execute with Shell script Post 302962101 by hawkman2k on Tuesday 8th of December 2015 10:21:10 AM
Old 12-08-2015
sed working on command line but file unchanged when execute with Shell script

I have a simple task to replace unix line feed end of line characters with carriage returns.

When I run the following “change file in place” sed instruction from the command line all the Line feeds are successfully replaced with Carriage returns.

Code:
sed -i 's/$/\r/' lf_file.txt

But that same command when run within a shell the file remains unchanged.
Within the shell I do change directory first and tried a fully qualified path as well.
I also tried having sed create an new file with carriage returns with the same negative results.

I have a feeling has something do with standard in or standard out.

Do I need some sort of redirect, pipe or here document when invoking the sed command within the shell?

I recall needing to some like this years ago with a similar command.

Last edited by Scrutinizer; 12-08-2015 at 11:49 AM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Please help: Build a sed command and execute it in a script

I am using an array to store some data (keys e.g 47975081_1215781266128), it can be assumed that it is key to other data. I want extract data from a file based on a couple of keys (range) and store the resulting data in a variable using the following command: sed -n... (9 Replies)
Discussion started by: gugs
9 Replies

2. Shell Programming and Scripting

"sed" command is not working in shell script

Hi All, I am not much strong in shell scripting... I am using sed command in my script to find and replace a string....... This is how script looks : ############# #!/usr/bin/ksh CONFIG_FILE=iom_test.txt FIND=`echo "NIS_FTP_SERVER1=123.456.iom.com"` REPLACE=`echo... (2 Replies)
Discussion started by: askumarece
2 Replies

3. Shell Programming and Scripting

How to execute the multiple line sql using shell script

Hi All, Please help me to write a shell script to execute the below sql query. select c.account_no,b.bill_no,a.pay_type,(b.total_due + b.recvd + b.adjusted + b.disputed + b.transferred) as amt_not_billed,d.cash_on_delivery, (select j.bill_no from billinfo_T y, bill_t j where... (1 Reply)
Discussion started by: girish.raos
1 Replies

4. Shell Programming and Scripting

Need help! command working ok when executed in command line, but fails when run inside a script!

Hi everyone, when executing this command in unix: echo "WM7 Fatal Alerts:", $(cat query1.txt) > a.csvIt works fine, but running this command in a shell script gives an error saying that there's a syntax error. here is content of my script: tdbsrvr$ vi hc.sh "hc.sh" 22 lines, 509... (4 Replies)
Discussion started by: 4dirk1
4 Replies

5. UNIX for Dummies Questions & Answers

How to execute command after telneting in shell script?

Hi , I have to write a shell script to telnet to specific host and execute the admin command there. Please help me to do that. Eg : telnet hostname portno admin command exit (3 Replies)
Discussion started by: arukuku
3 Replies

6. Shell Programming and Scripting

When i am trying to execute export command within a shell script it is saying command not found.

I am running the export command within a view to use that value inside my build script. But while executing it it is saying "export command not found" My code is as follows: -------------------------- #!/bin/sh user="test" DIR="/bldtmp/"$user VIEW="test.view1" echo "TMPDIR before export... (4 Replies)
Discussion started by: dchoudhury
4 Replies

7. Shell Programming and Scripting

sed Command new Line not working Tried many variations

Hi I have assigned an output of a command to $I. I try to print the input and put a new line after occurrence of the hostname which is assigned to $HOST1 ( Example: pwrm16 ) . First of all I need to get rid of the Colon after the host name pwrm16: and make it pwrm16 then I want to print the... (10 Replies)
Discussion started by: mnassiri
10 Replies

8. Shell Programming and Scripting

Modifying bash script to take each line in a file and execute command

I need to modify a bash script to to take each line in a file and execute command. I currently have this: #!/bin/bash if ; then echo "Lipsa IP"; exit; fi i=1 ip=$1 while ; do if ; then rand=`head -$i pass_file | tail -1` user=`echo $rand | awk '{print $1}'` pass=`echo $rand | awk '{print $2}'`... (3 Replies)
Discussion started by: galford
3 Replies

9. Shell Programming and Scripting

Execute ssh command with additional terminal command to any remote user not working script

Hello i am having an issue with bash script and this is the code now=$(cat hosts1.txt | awk '{print $2;}') while read n ;do ssh root@$now 'useradd test1; echo -e "test1\ntest1" | passwd test1 && echo "test1 ALL=(ALL:ALL) ALL" >> /etc/sudoers' When i execute only part with cat, it... (8 Replies)
Discussion started by: tomislav91
8 Replies

10. UNIX for Beginners Questions & Answers

Search a multi-line shell command output and execute logic based on result

The following is a multi-line shell command example: $cargo build Compiling prawn v0.1.0 (/Users/ag/rust/prawn) error: failed to resolve: could not find `setup_panix` in `human_panic` --> src/main.rs:14:22 | 14 | human_panic::setup_panix!(); | ... (2 Replies)
Discussion started by: yogi
2 Replies
GROUPS.CONF(5)						     ClusterShell User Manual						    GROUPS.CONF(5)

NAME
groups.conf - Configuration file for ClusterShell external node groups DESCRIPTION
The ClusterShell library obtains node groups configuration options from the system-wide configuration file /etc/clustershell/groups.conf. Additional configuration files are also read from the directories set by the groupsdir option, if present. See the groupsdir option below for further details. Configuration files have a format in the style of RFC 822 potentially composed of several sections which may be present in any order. There are two types of sections: Main and Group source: Main Global configuration options. There should be only one Main section. Group_source The Group_source section(s) define the configuration for each node group source (or namespace). This configuration consists in external commands definition (map, all, list and reverse). Only Group_source section(s) are allowed in additional configuration files. [Main] OPTIONS Configuration parameters of the Main section are described below. default Specify the default group source (group namespace) used by the NodeSet parser when the user does not explicitly specify the group source (eg. "@io"). groupsdir Optional list of directories where the ClusterShell library should look for .conf files which define group sources to use. Each file in these directories with the .conf suffix should contain one or more Group_source sections as documented in [Group_source] options below. These will be merged with the group sources defined in /etc/clustershell/groups.conf to form the complete set of group sources that ClusterShell will use. Duplicate Group_source sections are not allowed. Note: .conf files that are not readable by the current user are ignored. [Group_source] OPTIONS Configuration parameters of each group source section are described below. map Specify the external shell command used to resolve a group name into a nodeset, list of nodes or list of nodeset (separated by space characters or by carriage returns). The variable $GROUP is replaced before executing the command. all Optional external shell command that should return a nodeset, list of nodes or list of nodeset of all nodes for this group source. If not specified, the library will try to resolve all nodes by using the list external command in the same group source followed by map for each group. list Optional external shell command that should return the list of all groups for this group source (separated by space characters or by carriage returns). reverse Optional external shell command used to find the group(s) of a single node. The variable $NODE is previously replaced. If this upcall is not specified, the reverse operation is computed in memory by the library from the list and map external calls. Also, if the number of nodes to reverse is greater than the number of available groups, the reverse external command is avoided automati- cally. When the library executes a group source external shell command, the current working directory is previously set to the corresponding groupsdir. This allows the use of relative paths for third party files in the command. Each external command might return a non-zero return code when the operation is not doable. But if the call return zero, for instance, for a non-existing group, the user will not receive any error when trying to resolve such unknown group. The desired behaviour is up to the system administrator. RESOURCE USAGE
All external command results are cached in memory to avoid multiple calls. EXAMPLES
Simple configuration file for local groups and slurm partitions binding. groups.conf [Main] default: local #groupsdir: /etc/clustershell/groups.conf.d/ [local] map: sed -n 's/^$GROUP:(.*)/1/p' /etc/clustershell/groups list: sed -n 's/^([0-9A-Za-z_-]*):.*/1/p' /etc/clustershell/groups [slurm] map: sinfo -h -o "%N" -p $GROUP all: sinfo -h -o "%N" list: sinfo -h -o "%P" reverse: sinfo -h -N -o "%P" -n $NODE FILES
/etc/clustershell/groups.conf System-wide external node groups configuration file. /etc/clustershell/groups.conf.d/ Recommended directory for additional configuration files. SEE ALSO
clush(1), clubak(1), nodeset(1) http://clustershell.sourceforge.net/ AUTHOR
Stephane Thiell, CEA DAM <stephane.thiell@cea.fr> COPYRIGHT
CeCILL-C V1 1.6 2012-03-31 GROUPS.CONF(5)
All times are GMT -4. The time now is 09:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy