Hi, I need some help with this:
I'm making a script which does a couple of things with image files. The script is supposed to echo the number of each image it is processing like this:
The problem is with images with very long filenames, so I want to know how to limit the numer of characters of the output (maybe with sed or awk, but I prefer sed if it's possible).
I want to be able to turn this:
It's important to say that this limitation will be done over a variable and not a file.
I came across this solution which seems to work but it is applied on a file and not on a variable, and I need it to be applied on a variable
I'm doing this as part of a progress bar solution. I want it to be like pacman progress bar when downloading packages to be updated except that I want it to inform each processed file and the operation percentage in one line. I already accomplished this, the only things remaining are the one I'm asking for, and the animation of the progress bar to make it look like the pacman one.
Thanks in advance. Shadow_Reaper
---------- Post updated at 11:57 PM ---------- Previous update was at 11:53 PM ----------
The image I posted was intended to show the url of the solution. I will post it through this reply so that it can be seen
[THIS WEBSITE]
/shell-programming
-and-scripting/241327-li
mit-string-length-sed [.HTML HERE]
The actual solution is the first reply but I need to be able to do this on a variable rather than a file.
Last edited by Don Cragun; 10-13-2014 at 12:01 AM..
Reason: Chane IMG tag to URL tag.
Thats nice, i've had a similiar challenge a little back, but i wanted to maintain the file extensions + extra space for the possible incremented file number as well.
So that was my solution this, just copy pasted from source code:
Hope this helps
I want count number of characters / find the length of the 'wc -l' output
This is the command
bash-3.2$ gzcat /home/sid/file1.dat |wc -l
830752
So final out I want is 6 i.e lenght of 830752
I tried with awk
bash-3.2$ gzcat /home/sid/file1.dat |wc -l | awk '{print length ($0)... (3 Replies)
hi guys
how can i limit number of files in a disk or partition ?
or how can i make a limit to inode number for a disk or partition ?
ext3 or ext4 file system (1 Reply)
Hey guys and gals,
Working on a script to limit the reoccurrance of characters in a line.
sed "/\(.\).*\1/d" -i file.txt
sed "/\(.\).*\1.*\1/d" -i file.txt
sed "/\(.\).*\1.*\1.*1/d" -i file.txt
..
To limit character reoccurance with 1x, 2x, 3x etc.
However I would like to be able to... (2 Replies)
I have a script that outputs the weather on two lines.
If possibly I would like to set a character limit on them
Currently it outputs something like
but I would like to limit the lines so appends an ellipsis if nescessary:
This is the script
#! /bin/bash
curl -s --connect-timeout... (2 Replies)
In the vi editor, there seems to be some limit on the number of characters could be allowed in single line. I tried a line with characters up to 1880. It worked. But when i tried with something of 5000 characters, it doesnt work. Any suggestions.
Thanks in advance! (2 Replies)
Hello everyone.
I am trying to set up a monitor based on a "top" command statistic as follows:
top -bc -n1 > output.txt
I've put this command into a small script which is called by a cron... but there is something strange happening: the cron is limiting the output to output.txt to 80... (3 Replies)
Is there a way that I can limit number of commands that one user can run during period of time. For example Max 10 commands per senconds.:) (3 Replies)
Hi
Hi! I'm currently using AIX 5.2 and would like to know where can i find to see that there's a restriction on the number of login times a user can have. Example, I want give a 2 login per user but some one to give 3 login and some one have to give unlit login time (without logging off the... (2 Replies)
Hi,
I'm using AIX version 5.3 currently. I'm trying to create a user id, e.g. andyleong, which the system prompted the length is too long.
1. I would like to know is that the length of user id is limited to maximum 8 characters for AIX.
2. Is it apply to all versions of AIX?
If no... (2 Replies)