Number of lines from a gzip file (AIX) - gzip

How to count the number of lines in a gzip file?
wc -l can be used to get the number of lines from a normal file but what if it is a .gz file ??

Try to do this, It may help You.
gzcat filename.ZIP|wc -l

Related

Rename multiple files in SSH

I have a Centos server.
In SSH, I downloaded multiple mp4 files in a txt with this command:
wget -i urls.txt
Now I have a list of mp4 files in a directory. The problem is those mp4 files are named:
65464.mp4?md5=sdokj7SRuM-OKatFmdCJJg&expires=1570102642
45421.mp4?md5=sdokj56SRuM-OKatFmdCJJg&expires=157010277842
etc...
How do I remove ? and everything after in all files in this directory ( For example ?md5=sdokj7SRuM-OKatFmdCJJg&expires=1570102642 ) so it would change files name to:
65464.mp4
45421.mp4
etc...
Thank you.
The solution will depend upon what shell your CentOS system is running or has available. If you're running bash, you can do something as simple as:
for x in * ; do
mv $x ${x%%\?*}
done
This uses bash string variable manipulation techniques.
Another possible solution, still dependent upon shell features:
for x in * ; do
mv $x $(echo $x | sed "s/\?.*//")
done

Apache Redhat list how many times /foo/ was hit from command line

so far I have not been able to find an answer online or in any book. I would like to count how many times /foo/ was hit on my site. If anyone could help, Thank you!
Enter this on a command line:
grep -c '/foo/' /var/log/httpd/access_log
This will show the number of counts of "/foo/" inside of your apache acess log file.
There are more access log files:
access_log.2 access_log.4
access_log.1 access_log.3 access_log.5
If you want to see the result from older entries, then you can use
grep -c '/foo/' /var/log/httpd/access_log*
Result:
/var/log/httpd/access_log:46
/var/log/httpd/access_log.1:85
/var/log/httpd/access_log.2:46
/var/log/httpd/access_log.3:103
/var/log/httpd/access_log.4:70
/var/log/httpd/access_log.5:177
The path depends on your Redhat version.
http://www.itninja.com/blog/view/mysql-and-apache-profile-log-path-locations

Change Document Root with command lines

I'm setting up an Amazon Web Service Stack and I'd like to configure the Document Root in /etc/apache2/sites-enabled/000-default.conf which I currently do by modifying the document's DocumentRoot. I then reflect this change in /etc/apache2/apache2.conf. Is it possible to make these changes with command lines as opposed to opening and editing files? Thanks in advance.
You can do it with sed. I use following wrapper function, to make it more convenient:
replace_string () {
while :; do
case $1 in
file=?*) local file=${1#*=} ;;
replace=?*) local replace=${1#*=} ;;
with=?*) local with=${1#*=} ;;
*) break ;;
esac
shift
done
sudo sed -i -- "s/$replace/$with/ig" $file
}
replace_string file='/etc/apache2/sites-enabled/000-default.conf' \
replace='.*DocumentRoot.*' \
with='DocumentRoot path-to-your-document-root'
replace_string file='/etc/apache2/apache2.conf' \
replace='.*DocumentRoot.*' \
with='DocumentRoot "path-to-your-document-root"'
Mind that user running this script should be capable of using sudo without a password.
If you have httpd.conf file
I don't know if this is supported by the documentation or not (I couldn't see reference to it) but I found that appending will replace previous directives.
I stumbled upon this experimentally after becoming disillusioned with the cocophony of sed, grep and awk scripts that usually accompany this kind of question (see Modify config file using bash script).
In my case, I have a file called httpd_changes.conf which looks like this:
DocumentRoot "/my/new/web/dir"
<Directory "/my/new/web/dir">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Then when I set up the webserver (in my case it's in my Dockerfile) I run this prior to starting the httpd service:
cat httpd_changes.conf >> /etc/apache2/httpd.conf
If you don't have a httpd.conf file
This isn't my situation but as far as I can tell you can just put a new config file in your conf.d directory. Those files are read in alphabetically (according to this page https://superuser.com/questions/705297/in-what-order-does-apache-load-conf-files-and-which-ones) which is obviously much nicer than my hack.
You could try the following:
sed "s,/var/www/html,/my/new/web/dir,g" /etc/apache2/sites-enabled/000-default.conf
This will display the modification that would be made on your file.
The , is used as a custom delimiter to make the regex easier to read.
This example with replace all occurences of /var/www/html with /my/new/web/dir.
Add the -i flag to actually modify the file:
sed -i "s,/var/www/html,/my/new/web/dir,g" /etc/apache2/sites-enabled/000-default.conf

How do i get my CSV file?

I have done the following changes in the jmeter.properties file :
jmeter.save.saveservice.output_format=csv
jmeter.save.saveservice.assertion_results_failure_message=true
jmeter.save.saveservice.default_delimiter=|
But still I could not find where my .csv file.
Can anyone please help me.
Please see first answers to these posts:
How to save JMeter Aggregate Report results to a CSV file using command prompt?
How do I save my Apache jMeter results to a CSV file?.
In addition to your configuration done in jmeter.properties:
1) GUI:
2) CLI:
jmeter –n –t test.jmx -l test.csv
In test.csv you'll get results in csv format.

CVS header keywords not replaced

I have a unique problem with few of my files where the header information (Author/RCSFile/Date etc) is not automatically replaced when I commit my changes using Eclipse.
It comes back to blank:
######################## COPYRIGHT ################################
#
# $RCSfile$
# Owner: My Company
# $Revision$
# $Date$
#
# Last $Author$
#
# Description: Some description
#
####################################################################
Any idea why it would so? Out of 500 files I have only issue for 6 files.
Keyword substitution is configurable for each file (so that binaries aren't corrupted when you check them out). Do a cvs log -h on the offending files and check the "keyword substitution" line. The default is
keyword substitution: kv
Compare against other files that don't have this problem.
If that's not it, could there be non-printable characters in the file? Try cat -A filename if your system supports it, or cat -v filename if it doesn't (pipe the output to head or your favorite pager).
EDIT: Looks like the keyword substitution line was the problem. Use cvs admin to fix it. (I though it would be better to have this information in the answer rather than just in the comment.)