Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Shell script request

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 04-02-2012
udayakumar udayakumar is offline
Registered User
 
Join Date: Sep 2008
Last Activity: 31 January 2014, 4:56 PM EST
Posts: 10
Thanks: 2
Thanked 0 Times in 0 Posts
Shell script request

I've a master file which will contain 100 file names, The script should read file name from a master file and format the file as below in AIX.

input file


Code:
Filename

This
is
a
test
file

Output File


Code:
Filename|This is a test file

Thanks in advance



Code:
for file in $FileList; do 
echo $file; 
FileName=`basename $file`; 
sed  's/^M//g' $file> "${file}"2;
mv "${file}"2 "${file}"; 
sed '1d'  "${file}" >"${file}"1; 
mv "${file}"1 $file; 
sed 's/^$/|/'|tr "\n\r" "  " > "${file}"1
mv "${file}"1 $file; 
done

This is doing nothing. I'm not good at sed. Please help.

Last edited by methyl; 04-02-2012 at 12:42 PM..
Sponsored Links
    #2  
Old Unix and Linux 04-02-2012
DukeNuke2's Unix or Linux Image
DukeNuke2 DukeNuke2 is offline Forum Staff  
Soulman
 
Join Date: Jul 2006
Last Activity: 25 May 2017, 5:10 PM EDT
Location: Berlin, Germany
Posts: 5,693
Thanks: 72
Thanked 300 Times in 287 Posts
what have you tried? where do you need help?
Sponsored Links
    #3  
Old Unix and Linux 04-02-2012
methyl methyl is offline Forum Advisor  
Advisor
 
Join Date: Mar 2008
Last Activity: 8 June 2016, 9:58 PM EDT
Posts: 6,402
Thanks: 288
Thanked 676 Times in 645 Posts
What Operating System and version do you have? What Shell do you use?

You seem to refer to ^M a lot (which I interpret as intending to mean ctrl/M or carriage-return).
Is the input file a Microsoft format text file with carriage-return line-feed at the end of each line? Or is this a normal unix text file with just line-feed at the end of the line. Or is this an old MAC format text file with carriage-return at the end of each line?

Does Filename occur at the top of each file called Filename?
    #4  
Old Unix and Linux 04-02-2012
udayakumar udayakumar is offline
Registered User
 
Join Date: Sep 2008
Last Activity: 31 January 2014, 4:56 PM EST
Posts: 10
Thanks: 2
Thanked 0 Times in 0 Posts
Hi

I'm using bash shell in AIX 6.1
^M microsoft text
Yes its a Microsoft format text file with carriage-return line-feed at the end of each line

No the file name I've mentioned in example will be a free test like "Null in a Not Null column" or "0 Length Char". This will be standard in all files.
Sponsored Links
    #5  
Old Unix and Linux 04-02-2012
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 25 May 2017, 5:53 PM EDT
Location: Saskatchewan
Posts: 22,177
Thanks: 1,092
Thanked 4,171 Times in 3,860 Posts
Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.
Sponsored Links
    #6  
Old Unix and Linux 04-02-2012
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 25 May 2017, 5:53 PM EDT
Location: Saskatchewan
Posts: 22,177
Thanks: 1,092
Thanked 4,171 Times in 3,860 Posts
Duplicate topic, continue here.
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Request for shell script for listing directories, subdirs containing specific files. super210 Shell Programming and Scripting 4 10-11-2011 03:02 PM
Calling a request set from Unix shell Script swatipevekar Shell Programming and Scripting 4 06-15-2009 05:07 AM
Shell Script to provide "answers" to SSL Cert Request azvelocat Shell Programming and Scripting 2 04-16-2009 06:10 PM
How cgi(shell script) to receive the URL REQUEST from Front end (visual C++)? ryanW Shell Programming and Scripting 0 03-31-2009 05:27 AM



All times are GMT -4. The time now is 01:40 AM.