- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Increment a # field
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
06-13-2001 06:58 AM
06-13-2001 06:58 AM
Increment a # field
Thank you very much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2001 07:06 AM
06-13-2001 07:06 AM
Re: Increment a # field
1 s/abc/#abc/
w file-1
q
EOF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2001 07:16 AM
06-13-2001 07:16 AM
Re: Increment a # field
This would be my way:
F1="myfile.txt"
N=`line < ${F1}`
N2=`expr ${N} + 1`
echo "${N2}" > $F1
STAT=$?
exit ${STAT}
Regards, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2001 07:18 AM
06-13-2001 07:18 AM
Re: Increment a # field
Assume that in your file the second field, on the first line contains the number to be incremented. Then:
# awk '{if (NR==1){$2=$2+1};print $0}' filein > fileout
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2001 07:24 AM
06-13-2001 07:24 AM
Re: Increment a # field
Thanks again!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2001 02:48 PM
06-13-2001 02:48 PM
Re: Increment a # field
In the awk script I gave you, 'filein' would be replaced by your file (abc.txt). That's the input to 'awk'. The filtered file I simply called 'fileout'. In reality, you would run the 'awk' script and then overlaid 'filein' with 'fileout', like:
# awk... abc.txt > abc.new
# mv abc.new abc.txt
With my regards, Jim
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2001 08:46 PM
06-13-2001 08:46 PM
Re: Increment a # field
Cheers...
Satish.