- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Getting those spaces back
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2003 05:09 AM
11-20-2003 05:09 AM
The problem I have is when I write the lines to a file I do not get the leading spaces.
if a report looks like this:
============================
^L xxx 123
some header text
============================
The resolts will look like this:
============================
xxx 123
some header text
============================
How do I fix that?
Here is my script and how I use it.
Marty
--- strip_leading_ff.sh ---
#!/bin/sh
read a
a=`expr "$a" : ".\(.*\)"`
echo "$a"
while read a
do
echo "$a"
done
--- use ---
cat $the_text_file|$THE_PATH/strip_leading_ff.sh >$temp_file_name
mv $temp_file_name $the_text_file
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2003 05:18 AM
11-20-2003 05:18 AM
Re: Getting those spaces back
FF=$(print "\014") # FF character
sed -e "s/${FF}//" ${the_text_file} > ${temp_file_name}
Regards,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2003 05:25 AM
11-20-2003 05:25 AM
Re: Getting those spaces back
mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2003 06:37 AM
11-20-2003 06:37 AM
Re: Getting those spaces back
Mark your idea does the same as 'echo'
Can you help some more?
Marty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2003 07:18 AM
11-20-2003 07:18 AM
Re: Getting those spaces back
IFS='
'
2) use an awk script instead, which will be faster
#!/usr/bin/awk -f
BEGIN { ffcount=0;}
/^L/ { if ( ffcount == 0 ) {
sub("^L","",$0);
ffcount++;
}
print $0;
}
{ print $0;}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2003 07:38 AM
11-20-2003 07:38 AM
Re: Getting those spaces back
I haven't use 'awk' for any thing. looks like your script says if ther is a ^L make it null.
ould I use this in place of my script something like this:
cat file.txt|awk_script.sh >new_file.txt
Oh! the IFS'cr' worked great for the leading space thing. The other script strips off the first letter what ever it is.
Marty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2003 07:56 AM
11-20-2003 07:56 AM
Re: Getting those spaces back
FF=$(print "\014")
read a
a=${a#${FF}}
print "${A}"
The a=... line only removes the first character of a if it's a FF.
Regards,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2003 07:59 AM
11-20-2003 07:59 AM
Solutioncat file.txt|awk_script.sh >new_file.txt
yes that is how it would work.
an aside, awk scripts usually end in .awk, not .sh (they are not shell scripts).
an even easier way
ex -s +"/^L|s/^L//|wq" yourfile >/dev/null
looks like your script says if ther is a ^L make it null.
yes that is right
#/^L if the line contains a form feed
#if the counter equals zero
/^L/ { if ( ffcount == 0 ) {
# substitute nothing for the first formfeed
sub("^L","",$0);
#increment the counter so this is only done once
ffcount++;
}
#print the line without the formfeed if the first time
# or print the line
print $0;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2003 08:08 AM
11-20-2003 08:08 AM
Re: Getting those spaces back
didn't realize this.
modify the awk to this
#!/usr/bin/awk -f
NR==1 { sub("^L","",$0);
print $0;
}
{ print $0;}