Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Addition with the prefixing zeros included Post 302090992 by mph on Thursday 28th of September 2006 10:41:19 AM
Old 09-28-2006
How about something like this:
Code:
read x
z=`echo $x | awk '{print length}'`
y=`expr $x + 1`
printf "%0"$z"d\n" $y

I couln't get the typeset command to work on my machine. It complained about the -Z being and invalid option. But I'm pretty sure awk is the same on most *nix systems For some reason the "y=$(($x+1))" subtracted 1 instead of adding it. Expr seemed to fix that. Very strange, that's never happend before.

Last edited by mph; 09-28-2006 at 11:49 AM..
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

prefixing filenames

Hi,:cool: I have a list of files in a directory.I need to store them in a file with the prefix of @ by using a command.. ex:@p_po.plb @p_ebiz_roster_data.plb any idea pls. cheers RRK (2 Replies)
Discussion started by: ravi raj kumar
2 Replies

2. Shell Programming and Scripting

CSV formatting with prefixing, appending and padding field

Hi I have a very large csv file with some hundreds of thousands of rows of data. The data is in the following format: Up to four alpha numeric characters for the first word. This is either set as 2 characters followed by 2 spaces, or as a single 4character word. This is then followed by an 8... (7 Replies)
Discussion started by: meself
7 Replies

3. Shell Programming and Scripting

matching a pattern in a file & prefixing a word

Hi, In my shell script i have to match a patten in a file , if found i have to prefix the entair line by a "word" eg. pattern = "aaa" prefix= #123 file: bbbb xxx zzzz aaaa qqqq kkkk outPut file: bbbb xxx ... (5 Replies)
Discussion started by: shivarajM
5 Replies

4. Solaris

What update level included fcinfo?

Hi all first post here. quick question what Solaris 10 update level included this utility? I have a bunch of Sun boxes at varying levels of Solaris 10 some have it some do not. When I do my install I take the full option for the packages to install on all the systems. thanks in advance... Mike (4 Replies)
Discussion started by: mike_243us
4 Replies

5. Shell Programming and Scripting

Prefixing test case methods with letter 'test'

Hi, I have a Python unit test cases source code file which contains more than a hundred test case methods. In that, some of the test case methods already have prefix 'test' where as some of them do not have. Now, I need to add the string 'test' (case-sensitive) as a prefix to those of the... (5 Replies)
Discussion started by: royalibrahim
5 Replies

6. Shell Programming and Scripting

Rm -rf file.txt~ included in the first step?

I need to shred and delete a file after a certain time. Therefore I use shred -z /path/to/file.txt | rm -rf /path/to/file.txtIt works well, but typing in that very directory ls -shiI still see the so called backup-copy lets say file.txt~ When running bleachbit it will disappear thoroughly.... (3 Replies)
Discussion started by: 1in10
3 Replies

7. UNIX for Beginners Questions & Answers

Date included

#!/usr/bin/ksh # This script reads the *.rpt files created by xenos during job execution. # The job name, jobid, number of pages processed and pdf files created for each job # are added to the xenoshistory.txt file Currently the ouput file looks like this but I need a date where the... (3 Replies)
Discussion started by: bcarosi
3 Replies
vec(2rheolef)							    rheolef-6.1 						     vec(2rheolef)

NAME
vec - vector in distributed environment (rheolef-6.1) SYNOPSYS
STL-like vector container for a sequential or distributed memory machine model. Additional operation fom classical algebra. EXAMPLE
A sample usage of the class is: int main(int argc, char**argv) { environment distributed(argc, argv); vec<double> x(100, 3.14); dout << x << endl; } IMPLEMENTATION NOTE
Implementation use array<T,M>. IMPLEMENTATION
template <class T, class M = rheo_default_memory_model> class vec : public array<T, M> { public: // typedef: typedef array<T, M> base; typedef typename base::size_type size_type; typedef std::ptrdiff_t difference_type; #ifdef TODO // pb compile avec boost sur foehn: typedef typename base::difference_type difference_type; #endif // TODO typedef basic_range<size_type, difference_type> range_type; typedef typename base::reference reference; typedef typename base::const_reference const_reference; typedef typename base::iterator iterator; typedef typename base::const_iterator const_iterator; // allocator/deallocator: vec (const distributor& ownership, const T& init_val = std::numeric_limits<T>::max()); vec(size_type dis_size = 0, const T& init_val = std::numeric_limits<T>::max()); void resize ( const distributor& ownership, const T& init_val = std::numeric_limits<T>::max()); void resize ( size_type size = 0, const T& init_val = std::numeric_limits<T>::max()); // accessors: const_reference operator[] (size_type i) const; reference operator[] (size_type i); T max_abs () const; // range: vec(const vec_range<T,M>& vr); vec(const vec_range_const<T,M>& vr); vec<T,M>& operator= (const vec_range<T,M>& vr); vec<T,M>& operator= (const vec_range_const<T,M>& vr); vec_range_const<T,M> operator[] (const range_type& r) const; vec_range<T,M> operator[] (const range_type& r); // assignment to a constant: vec<T,M>& operator= (const int& expr); vec<T,M>& operator= (const T& expr); // expression template: template<typename Expr> vec (const Expr& expr); template<typename Expr> vec<T,M>& operator= (const vec_expr<Expr>& expr); template<typename Expr> vec<T,M>& operator+= (const Expr& expr); template<typename Expr> vec<T,M>& operator-= (const Expr& expr); // initializer list (c++ 2011): #ifdef _RHEOLEF_HAVE_STD_INITIALIZER_LIST vec (const std::initializer_list<vec_concat_value<T,M> >& init_list); vec<T,M>& operator= (const std::initializer_list<vec_concat_value<T,M> >& init_list); #endif // _RHEOLEF_HAVE_STD_INITIALIZER_LIST }; rheolef-6.1 rheolef-6.1 vec(2rheolef)
All times are GMT -4. The time now is 07:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy