Skip to content

Tag: bash

Variable passed through environment not available in script

I’m trying to write an if/elif/else statement where if a variable equals “Full” it will cat a file and if the same variable equals “Quick” it will read a different, smaller file. The variable is being set outside of the script and is being exported by export var1=Quick I have Whe…

Unable to create a 777 file on Linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack …

Uniq skipping middle part of the line when comparing lines

Sample file aabbccddeeffgghhiijj aabbccddeellgghhiijj aabbccddeeffgghhiijj I want to skip 6th field ‘ff’ when comparing for an unique line, also I want the count of # of duplicate lines in front. I tried this, without any luck: Expected output 3 aabbccddee*gghhiijj Answer Discussion With –un…

sed with variable as argument in bash script

I am trying to write a bash script to scan for authorized_keys files and remove the keys of a couple previous employees if found. I am having one heck of a time figuring out the escaping for the sed command at the end. I am using commas instead of / since / can show up in the ssh-key. Any help

Counting all .class files

I want to count all .class file in my project directory. I am working on ubuntu. I can list all the class file like this – It lists a lot of .class files. But I want to know the count of these .class files. Is there any way to do this in linux. Thanks. Answer Use wc -l. wc stands

command blkid don’t show my partitions UUID

I’m using Ubuntu. command blkid or blk /dev/sda2 in LPIC-1 module 104.3 (mounting and unmounting). but these commands don’t show me the expected results. blkid is installed and also I can see man blkid !!! Could you guide me to fix this? Answer Run sudo blkid After that you will be able to get the…

How to abort if command fails in Unix shell?

I’m not very great with shell scripting and still couldn’t find a solution to this. I want to run a command gulp tslint and if it returns errors, abort the script. So far I tried gulp tslint || exit 1 with no success. I think it somehow is returning true, even though it has errors when i run it on

how to grep lines according to 6th field contents

I would like to know how to filter lines according to the mem usage: I would like to be able to find only the PIDs that (RES mem usage) exceed 5GB Explicitly, I have the following lines and I’d like to grep only the lines where the 6th field is larger than 5 GB EDIT: Note that sorting is not